Skip to content

Commit

Permalink
Merge pull request #33392 from owncloud/occ-config-key-test
Browse files Browse the repository at this point in the history
Add cli test for adding, deleting and listing system and app configs
  • Loading branch information
phil-davis authored Nov 2, 2018
2 parents 2c0b01f + 8d70e94 commit 79fb19c
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
127 changes: 127 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,133 @@ public function theBackgroundJobsModeShouldBe($mode) {
PHPUnit_Framework_Assert::assertEquals($mode, \trim($lastOutput));
}

/**
* @When the administrator adds a config key :key with value :value in app :app using the occ command
*
* @param string $key
* @param string $value
* @param string $app
*
* @return void
*/
public function theAdministratorAddsAConfigKeyWithValueInAppUsingTheOccCommand($key, $value, $app) {
$this->featureContext->invokingTheCommand(
"config:app:set --value ${value} ${app} ${key}"
);
}

/**
* @When the administrator deletes the config key :key of app :app using the occ command
*
* @param string $key
* @param string $app
*
* @return void
*/
public function theAdministratorDeletesTheConfigKeyOfAppUsingTheOccCommand($key, $app) {
$this->featureContext->invokingTheCommand(
"config:app:delete ${app} ${key}"
);
}

/**
* @When the administrator adds a system config key :key with value :value using the occ command
*
* @param string $key
* @param string $value
*
* @return void
*/
public function theAdministratorAddsASystemConfigKeyWithValueUsingTheOccCommand($key, $value) {
$this->featureContext->invokingTheCommand(
"config:system:set --value ${value} ${key}"
);
}

/**
* @When the administrator deletes a system config key :key using the occ command
*
* @param string $key
*
* @return void
*/
public function theAdministratorDeletesASystemConfigKeyUsingTheOccCommand($key) {
$this->featureContext->invokingTheCommand(
"config:system:delete ${key}"
);
}

/**
* @Then the system config key :key with value :value should exist
*
* @param string $key
* @param string $value
*
* @return void
*/
public function theSystemConfigKeyWithValueShouldExist($key, $value) {
$config = \trim($this->featureContext->getSystemConfigValue($key));
PHPUnit_Framework_Assert::assertSame($value, $config);
}

/**
* @Then the system config key :key should not exist
*
* @param string $key
*
* @return void
*/
public function theSystemConfigKeyShouldNotExist($key) {
PHPUnit_Framework_Assert::assertEmpty($this->featureContext->getSystemConfig($key)['stdOut']);
}

/**
* @When the administrator lists the config keys
*
* @return void
*/
public function theAdministratorListsTheConfigKeys() {
$this->featureContext->invokingTheCommand(
"config:list"
);
}

/**
* @Then the command output should contain the apps configs
*
* @return void
*/
public function theCommandOutputShouldContainTheAppsConfigs() {
$config_list = \json_decode($this->featureContext->getStdOutOfOccCommand(), true);
PHPUnit_Framework_Assert::assertArrayHasKey(
'apps',
$config_list,
"The occ output doesnot contain apps configs"
);
PHPUnit_Framework_Assert::assertNotEmpty(
$config_list['apps'],
"The occ output doesnot contain apps configs"
);
}

/**
* @Then the command output should contain the system configs
*
* @return void
*/
public function theCommandOutputShouldContainTheSystemConfigs() {
$config_list = \json_decode($this->featureContext->getStdOutOfOccCommand(), true);
PHPUnit_Framework_Assert::assertArrayHasKey(
'system',
$config_list,
"The occ output doesnot contain system configs"
);
PHPUnit_Framework_Assert::assertNotEmpty(
$config_list['system'],
"The occ output doesnot contain system configs"
);
}

/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
35 changes: 35 additions & 0 deletions tests/acceptance/features/cliMain/configKey.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@cli
Feature: add and delete app configs using occ command

As an administrator
I want to be able to add and delete app configs via the command line

Scenario: admin adds and deletes a config for an app using the occ command
When the administrator adds a config key "con" with value "conkey" in app "core" using the occ command
Then the command should have been successful
And the command output should contain the text 'Config value con for app core set to conkey'
And the config key "con" of app "core" must have value "conkey"
When the administrator deletes the config key "con" of app "core" using the occ command
Then the command should have been successful
And the command output should contain the text 'Config value con of app core deleted'
And the app "core" should not have config key "con"

Scenario: admin adds and deletes a system config
When the administrator adds a system config key "con" with value "conkey" using the occ command
Then the command should have been successful
And the command output should contain the text 'System config value con set to string conkey'
And the system config key "con" with value "conkey" should exist
When the administrator deletes a system config key "con" using the occ command
Then the command should have been successful
And the command output should contain the text 'System config value con deleted'
And the system config key "con" should not exist

Scenario: admin can list system config
When the administrator lists the config keys
Then the command should have been successful
And the command output should contain the system configs

Scenario: admin can list app config
When the administrator lists the config keys
Then the command should have been successful
And the command output should contain the apps configs

0 comments on commit 79fb19c

Please sign in to comment.