Skip to content

Commit

Permalink
Test app:getpath
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Nov 22, 2018
1 parent f6501e8 commit 4a10b97
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,19 @@ public function theAdministratorGetsTheListOfAppsUsingTheOccCommand() {
);
}

/**
* @When the administrator checks the location of the :appName app using the occ command
*
* @param string $appName
*
* @return void
*/
public function theAdministratorChecksTheLocationOfTheAppUsingTheOccCommand($appName) {
$this->featureContext->invokingTheCommand(
"app:getpath $appName"
);
}

/**
* @When the administrator disables user :username using the occ command
*
Expand Down Expand Up @@ -585,6 +598,41 @@ public function theAppNameReturnedByTheOccCommandShouldBe($appName) {
PHPUnit_Framework_Assert::assertEquals($appName, \key($lastOutputArray['apps']));
}

/**
* @Then the path returned by the occ command should be inside one of the apps paths in the config for the :appName app
*
* @param string $appName
*
* @return void
* @throws \Exception
*/
public function thePathReturnedByTheOccCommandShouldBeInsideOneOfTheAppsPathInTheConfig($appName) {
$appPath = $this->featureContext->getStdOutOfOccCommand();

$this->featureContext->invokingTheCommand("config:list");
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
$configOutputArray = \json_decode($lastOutput, true);

// Default apps location is '${INSTALLED_LOCATION}/apps/${appName}
if (\substr_compare($appPath, '/apps/${appName}', 0)) {
return;
}

// We can also set it in the `apps_paths` in the `config`
if (isset($configOutputArray['system']['apps_paths'])) {
$appPaths = $configOutputArray['system']['apps_paths'];

foreach ($appPaths as $path) {
if (\substr_compare($appPath, $path['path'], 0)) {
return;
}
}
}

// if it's neither in the default location, nor in `apps_paths`, where it could be?
throw new Exception(__METHOD__ . "App path $appPath was not found in the config.");
}

/**
* @Then the app enabled status of app :appName should be :appStatus
*
Expand Down
9 changes: 9 additions & 0 deletions tests/acceptance/features/cliProvisioning/getApps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ Feature: get apps
| files_sharing |
| updatenotification |
| files_external |

Scenario: admin checks the path of the given app
When the administrator checks the location of the "testing" app using the occ command
Then the command should have been successful
And the path returned by the occ command should be inside one of the apps paths in the config for the "testing" app

Scenario: admin checks the path for non-existing app
When the administrator checks the location of the "not-existing-app" app using the occ command
Then the command should have failed with exit code 1

0 comments on commit 4a10b97

Please sign in to comment.