diff --git a/admin/tests/behat/behat_admin.php b/admin/tests/behat/behat_admin.php index 87a00b6cdad..72ca34b928b 100644 --- a/admin/tests/behat/behat_admin.php +++ b/admin/tests/behat/behat_admin.php @@ -135,6 +135,25 @@ class behat_admin extends behat_base { } } + /** + * Checks a config value is the one expected. + * + * @Then /^config value "(?P[^"]+)" should be "(?P[^"]*)"$/ + * @param string $name Config name + * @param string $expectedvalue Expected value + */ + public function config_value_should_be($name, $expectedvalue) { + global $CFG; + if (property_exists($CFG, $name)) { + $value = (string)$CFG->{$name}; + } else { + $value = ''; + } + if ($value !== $expectedvalue) { + throw new Exception('Config setting "' . $name . '" value "' . $value . '" unexpected"'); + } + } + /** * Waits with the provided params if we are running a JS session. * diff --git a/lib/tests/behat/silly.feature b/lib/tests/behat/silly.feature new file mode 100644 index 00000000000..045cea62d2d --- /dev/null +++ b/lib/tests/behat/silly.feature @@ -0,0 +1,16 @@ +@silly +Feature: Check config variables + In order to check Behat resets config variables + As a developer + I want to see if it does or not + + Scenario: Set a silly admin setting and a real one + Given the following config values are set as admin: + | config | value | + | sillyvariable | 666 | + | enableoutcomes | 1 | + + @silly2 + Scenario: Check both admin settings + Then config value "enableoutcomes" should be "0" + And config value "sillyvariable" should be ""