Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,55 @@ public function getLastJobIdForJob($job) {
return false;
}

/**
* @Then the system config key :key from the last command output should match value :value of type :type
*
* @param string $key
* @param string $value
* @param string $type
*
* @return void
*/
public function theSystemConfigKeyFromLastCommandOutputShouldContainValue(
$key, $value, $type
) {
$configList = \json_decode(
$this->featureContext->getStdOutOfOccCommand(), true
);
$systemConfig = $configList['system'];

// convert the value to it's respective type based on type given in the type column
if ($type === 'boolean') {
$value = $value === 'true' ? true : false;
Comment thread
individual-it marked this conversation as resolved.
} elseif ($type === 'integer') {
$value = (int) $value;
} elseif ($type === 'json') {
// if the expected value of the key is a json
// match the value with the regular expression
$actualKeyValuePair = \json_encode(
$systemConfig[$key], JSON_UNESCAPED_SLASHES
);

PHPUnit\Framework\Assert::assertThat(
$actualKeyValuePair,
PHPUnit\Framework\Assert::matchesRegularExpression($value)
);
return;
}

if (!\array_key_exists($key, $systemConfig)) {
PHPUnit\Framework\Assert::fail(
"system config doesn't contain key: " . $key
);
}

PHPUnit\Framework\Assert::assertEquals(
$value,
$systemConfig[$key],
"config: $key doesn't contain value: $value"
);
}

/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/features/cliMain/configKey.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,22 @@ Feature: add and delete app configs using occ command
Then the command should have been successful
And the command output should contain the apps configs

Scenario: app directory should be listed in the config file
When the administrator lists the config keys
Then the command should have been successful
And the system config key "apps_paths" from the last command output should match value '/\"url\":\"\/apps\",\"writable\":false/' of type "json"

Scenario: app-external directory should be listed in the config
When the administrator lists the config keys
Then the command should have been successful
And the system config key "apps_paths" from the last command output should match value '/\"url\":\"\/apps-external\",\"writable\":true/' of type "json"

Scenario: log time zone should be listed in the config file
When the administrator lists the config keys
Then the command should have been successful
And the system config key "logtimezone" from the last command output should match value "UTC" of type "string"

Scenario: server installed should be listed in the config file
When the administrator lists the config keys
Then the command should have been successful
And the system config key "installed" from the last command output should match value "true" of type "boolean"