X Tutup
Skip to content

Commit cc48f1f

Browse files
committed
filter app:list output by enabled or disabled apps
1 parent b78483c commit cc48f1f

File tree

4 files changed

+242
-6
lines changed

4 files changed

+242
-6
lines changed

changelog/unreleased/36520

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Enhancement: Add enabled and disabled filter options to occ app:list command
2+
3+
The occ app:list command now supports the --enabled and --disabled options
4+
5+
occ app:list --enabled
6+
Displays just the enabled apps.
7+
8+
occ app:list --disabled
9+
Displays just the disabled apps.
10+
11+
If a disabled app was enabled in the past, then the previously-enabled version
12+
of the app is now displayed in the disabled apps list.
13+
14+
https://github.com/owncloud/core/pull/36520

core/Command/App/ListApps.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ protected function configure() {
5050
$this
5151
->setName('app:list')
5252
->setDescription('List all available apps.')
53+
->addOption(
54+
'enabled',
55+
'e',
56+
InputOption::VALUE_NONE,
57+
'Only display enabled apps.'
58+
)
59+
->addOption(
60+
'disabled',
61+
'd',
62+
InputOption::VALUE_NONE,
63+
'Only display disabled apps.'
64+
)
5365
->addArgument(
5466
'search-pattern',
5567
InputArgument::OPTIONAL,
@@ -96,14 +108,19 @@ protected function execute(InputInterface $input, OutputInterface $output) {
96108

97109
$apps = ['enabled' => [], 'disabled' => []];
98110

99-
\sort($enabledApps);
100-
foreach ($enabledApps as $app) {
101-
$apps['enabled'][$app] = (isset($versions[$app])) ? $versions[$app] : true;
111+
$neitherSpecified = !($input->getOption('enabled') || $input->getOption('disabled'));
112+
if ($input->getOption('enabled') || $neitherSpecified) {
113+
\sort($enabledApps);
114+
foreach ($enabledApps as $app) {
115+
$apps['enabled'][$app] = (isset($versions[$app])) ? $versions[$app] : true;
116+
}
102117
}
103118

104-
\sort($disabledApps);
105-
foreach ($disabledApps as $app) {
106-
$apps['disabled'][$app] = (isset($versions[$app])) ? $versions[$app] : null;
119+
if ($input->getOption('disabled') || $neitherSpecified) {
120+
\sort($disabledApps);
121+
foreach ($disabledApps as $app) {
122+
$apps['disabled'][$app] = ($input->getOption('disabled') && isset($versions[$app])) ? $versions[$app] : null;
123+
}
107124
}
108125

109126
$this->writeAppList($input, $output, $apps);

tests/acceptance/features/bootstrap/AppManagementContext.php

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,152 @@ public function adminGetsPathForApp($appId) {
159159
);
160160
}
161161

162+
/**
163+
* @When the administrator lists the apps using the occ command
164+
*
165+
* @return void
166+
*/
167+
public function adminListsTheApps() {
168+
$occStatus = $this->featureContext->runOcc(
169+
['app:list', '--no-ansi']
170+
);
171+
}
172+
173+
/**
174+
* @When the administrator lists the enabled apps using the occ command
175+
*
176+
* @return void
177+
*/
178+
public function adminListsTheEnabledApps() {
179+
$occStatus = $this->featureContext->runOcc(
180+
['app:list', '--enabled', '--no-ansi']
181+
);
182+
}
183+
184+
/**
185+
* @When the administrator lists the disabled apps using the occ command
186+
*
187+
* @return void
188+
*/
189+
public function adminListsTheDisabledApps() {
190+
$occStatus = $this->featureContext->runOcc(
191+
['app:list', '--disabled', '--no-ansi']
192+
);
193+
}
194+
195+
/**
196+
* @When the administrator lists the enabled and disabled apps using the occ command
197+
*
198+
* @return void
199+
*/
200+
public function adminListsTheEnabledAndDisabledApps() {
201+
$occStatus = $this->featureContext->runOcc(
202+
['app:list', '--enabled', '--disabled', '--no-ansi']
203+
);
204+
}
205+
206+
/**
207+
* @Then app :appId with version :appVersion should have been listed in the enabled apps section
208+
*
209+
* @param string $appId
210+
* @param string $appVersion
211+
*
212+
* @return void
213+
*/
214+
public function appWithVersionShouldHaveBeenListedInTheEnabledAppsSection(
215+
$appId, $appVersion
216+
) {
217+
$commandOutput = $this->featureContext->getStdOutOfOccCommand();
218+
$expectedStartOfOutput = "Enabled:";
219+
Assert::assertEquals(
220+
$expectedStartOfOutput,
221+
\substr($commandOutput, 0, 8),
222+
"app:list command output did not start with '$expectedStartOfOutput'"
223+
);
224+
$startOfDisabledSection = \strpos($commandOutput, "Disabled:");
225+
if ($startOfDisabledSection) {
226+
$commandOutput = \substr($commandOutput, 0, $startOfDisabledSection);
227+
}
228+
$expectedString = "- $appId: $appVersion";
229+
Assert::assertNotFalse(
230+
\strpos($commandOutput, $expectedString),
231+
"app:list output did not contain '$expectedString' in the enabled section"
232+
);
233+
}
234+
235+
/**
236+
* @Then app :appId with version :appVersion should have been listed in the disabled apps section
237+
*
238+
* @param string $appId
239+
* @param string $appVersion
240+
*
241+
* @return void
242+
*/
243+
public function appWithVersionShouldHaveBeenListedInTheDisabledAppsSection(
244+
$appId, $appVersion
245+
) {
246+
$commandOutput = $this->featureContext->getStdOutOfOccCommand();
247+
$startOfDisabledSection = \strpos($commandOutput, "Disabled:");
248+
Assert::assertNotFalse(
249+
$startOfDisabledSection,
250+
"app:list output did not contain the disabled section"
251+
);
252+
$commandOutput = \substr($commandOutput, $startOfDisabledSection);
253+
$expectedString = "- $appId: $appVersion";
254+
Assert::assertNotFalse(
255+
\strpos($commandOutput, $expectedString),
256+
"app:list output did not contain '$expectedString' in the disabled section"
257+
);
258+
}
259+
260+
/**
261+
* @Then app :appId should have been listed in the disabled apps section
262+
*
263+
* @param string $appId
264+
*
265+
* @return void
266+
*/
267+
public function appShouldHaveBeenListedInTheDisabledAppsSection($appId) {
268+
$commandOutput = $this->featureContext->getStdOutOfOccCommand();
269+
$startOfDisabledSection = \strpos($commandOutput, "Disabled:");
270+
Assert::assertNotFalse(
271+
$startOfDisabledSection,
272+
"app:list output did not contain the disabled section"
273+
);
274+
$commandOutput = \substr($commandOutput, $startOfDisabledSection);
275+
$expectedString = "- $appId";
276+
Assert::assertNotFalse(
277+
\strpos($commandOutput, $expectedString),
278+
"app:list output did not contain '$expectedString' in the disabled section"
279+
);
280+
}
281+
282+
/**
283+
* @Then the enabled apps section should not exist
284+
*
285+
* @return void
286+
*/
287+
public function theEnabledAppsSectionShouldNotExist() {
288+
$commandOutput = $this->featureContext->getStdOutOfOccCommand();
289+
Assert::assertFalse(
290+
\strpos($commandOutput, "Enabled:"),
291+
"app:list output contains the enabled section but it should not"
292+
);
293+
}
294+
295+
/**
296+
* @Then the disabled apps section should not exist
297+
*
298+
* @return void
299+
*/
300+
public function theDisabledAppsSectionShouldNotExist() {
301+
$commandOutput = $this->featureContext->getStdOutOfOccCommand();
302+
Assert::assertFalse(
303+
\strpos($commandOutput, "Disabled:"),
304+
"app:list output contains the disabled section but it should not"
305+
);
306+
}
307+
162308
/**
163309
* @Then the path to :appId should be :dir
164310
*
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@cli @skipWhenTestingRemoteSystems
2+
Feature: list apps
3+
As an admin
4+
I want to be able to get a list of apps that are enabled and/or disabled
5+
So that I can manage the apps in my ownCloud
6+
7+
Scenario: list all the apps
8+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
9+
And app "testapp1" has been enabled
10+
And app "testapp2" with version "5.6.7" has been put in dir "apps"
11+
And app "testapp2" has been disabled
12+
When the administrator lists the apps using the occ command
13+
Then the command should have been successful
14+
And app "testapp1" with version "2.3.4" should have been listed in the enabled apps section
15+
And app "testapp2" should have been listed in the disabled apps section
16+
17+
Scenario: list all the apps by specifying both "enabled" and "disabled"
18+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
19+
And app "testapp1" has been enabled
20+
And app "testapp2" with version "5.6.7" has been put in dir "apps"
21+
And app "testapp2" has been enabled
22+
And app "testapp2" has been disabled
23+
When the administrator lists the enabled and disabled apps using the occ command
24+
Then the command should have been successful
25+
And app "testapp1" with version "2.3.4" should have been listed in the enabled apps section
26+
And app "testapp2" with version "5.6.7" should have been listed in the disabled apps section
27+
28+
Scenario: the version of a disabled app is not displayed on a full list even if it has previously been enabled
29+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
30+
And app "testapp1" has been enabled
31+
And app "testapp1" has been disabled
32+
When the administrator lists the apps using the occ command
33+
Then the command should have been successful
34+
And app "testapp1" should have been listed in the disabled apps section
35+
36+
Scenario: the version of a disabled app is displayed if disabled apps are specifically requested
37+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
38+
And app "testapp1" has been enabled
39+
And app "testapp1" has been disabled
40+
When the administrator lists the disabled apps using the occ command
41+
Then the command should have been successful
42+
And app "testapp1" with version "2.3.4" should have been listed in the disabled apps section
43+
44+
Scenario: list only the enabled apps
45+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
46+
And app "testapp1" has been enabled
47+
When the administrator lists the enabled apps using the occ command
48+
Then the command should have been successful
49+
And app "testapp1" with version "2.3.4" should have been listed in the enabled apps section
50+
And the disabled apps section should not exist
51+
52+
Scenario: list only the disabled apps
53+
Given app "testapp1" with version "2.3.4" has been put in dir "apps"
54+
And app "testapp1" has been enabled
55+
And app "testapp1" has been disabled
56+
When the administrator lists the disabled apps using the occ command
57+
Then the command should have been successful
58+
And app "testapp1" with version "2.3.4" should have been listed in the disabled apps section
59+
And the enabled apps section should not exist

0 commit comments

Comments
 (0)
X Tutup