From 4241762a1b2f5cbae636572de3ecf84009970fbd Mon Sep 17 00:00:00 2001 From: Daniel Thee Roperto Date: Fri, 23 Sep 2016 23:25:08 +1000 Subject: [PATCH] Issue #46 - Implemented a basic behat test to check saving the default settings. --- tests/behat/auth_outage_configuration.feature | 35 ----------------- tests/behat/behat_auth_outage.php | 39 +++++++++++++++++++ tests/behat/default_settings.feature | 23 +++++++++++ 3 files changed, 62 insertions(+), 35 deletions(-) delete mode 100644 tests/behat/auth_outage_configuration.feature create mode 100644 tests/behat/behat_auth_outage.php create mode 100644 tests/behat/default_settings.feature diff --git a/tests/behat/auth_outage_configuration.feature b/tests/behat/auth_outage_configuration.feature deleted file mode 100644 index 5022824..0000000 --- a/tests/behat/auth_outage_configuration.feature +++ /dev/null @@ -1,35 +0,0 @@ -@auth @auth_outage @javascript -Feature: Test outage plugin works as expected. - In order to check if this plugin works - As an admin - I need to go through all configuration to ensure they can be changed and are consistent. - - Background: - Given I log in as "admin" - -# Scenario: Check if I can navigate to the default settings. -# Given I navigate to "Defaults" node in "Site administration > Plugins > Authentication > Outage" -# Then I should see "Outage Defaults" - - Scenario: Check if I can add a new outage. - Given I navigate to "Manage" node in "Site administration > Plugins > Authentication > Outage" - And I should see "Outages List" - When I click on "Create Outage" "link" - And I set the following fields to these values: - | starttime[day] | 2 | - | starttime[month] | January | - | starttime[year] | 2016 | - | starttime[hour] | 22 | - | starttime[minute] | 00 | - | stoptime[day] | 2 | - | stoptime[month] | January | - | stoptime[year] | 2016 | - | stoptime[hour] | 23 | - | stoptime[minute] | 30 | - | warningduration[number] | 90 | - | warningduration[timeunit] | minutes | - | title | My New Outage | - | description[text] | This is a test outage. | - And I press "Save changes" - Then I should see "My New Outage" - And I should see "This is a test outage." diff --git a/tests/behat/behat_auth_outage.php b/tests/behat/behat_auth_outage.php new file mode 100644 index 0000000..4a011d8 --- /dev/null +++ b/tests/behat/behat_auth_outage.php @@ -0,0 +1,39 @@ +. + +/** + * Steps definitions related to auth_outage. + * + * @package auth_outage + * @author Daniel Thee Roperto + * @copyright 2016 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. + +require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); + +class behat_auth_outage extends behat_base { + /** + * @Given /^The authentication plugin "([^"]*)" is enabled$/ + */ + public function theAuthenticationPluginIsEnabled($auth) { + set_config('auth', $auth); + \core\session\manager::gc(); // Remove stale sessions. + core_plugin_manager::reset_caches(); + } +} \ No newline at end of file diff --git a/tests/behat/default_settings.feature b/tests/behat/default_settings.feature new file mode 100644 index 0000000..3198d6d --- /dev/null +++ b/tests/behat/default_settings.feature @@ -0,0 +1,23 @@ +@auth @auth_outage @javascript +Feature: Test changing the default settings. + In order to check if I can set the default settings + As an admin + I need to go set the default values and check if they are using for new outages + + Background: Always login as admin and enable the auth_outage plugin. + Given The authentication plugin "outage" is enabled + And I log in as "admin" + + Scenario: Check if I can navigate to the default settings. + Given I navigate to "Default Settings" node in "Site administration > Plugins > Authentication > Outage manager" + When I set the following fields to these values: + | s_auth_outage_default_autostart | bool | + | s_auth_outage_default_duration | 123 | + | s_auth_outage_default_warning_duration | 456 | + | s_auth_outage_default_warning_title | My Behat Outage {{start}} | + | s_auth_outage_default_warning_description | My outage {{stop}}. | + | s_auth_outage_css | /* Some CSS. */ | + And I press "Save changes" + And I should see "Changes Saved" +# And I wait "600" seconds +# And I should see "This is a test outage."