Issue #46 - Implemented a basic behat test to check saving the default settings.

This commit is contained in:
Daniel Thee Roperto
2016-09-23 23:25:08 +10:00
parent 375c76dbf8
commit 4241762a1b
3 changed files with 62 additions and 35 deletions

View File

@@ -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."

View File

@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Steps definitions related to auth_outage.
*
* @package auth_outage
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
* @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();
}
}

View File

@@ -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 <b>{{stop}}</b>. |
| 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."