mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Issue #46 - Improved behat for default settings.
This commit is contained in:
@@ -25,15 +25,48 @@
|
||||
|
||||
// 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');
|
||||
use Behat\Behat\Tester\Exception\PendingException;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use Behat\Mink\Exception\ExpectationException;
|
||||
|
||||
require_once(__DIR__.'/../../../../lib/behat/behat_base.php');
|
||||
|
||||
class behat_auth_outage extends behat_base {
|
||||
/**
|
||||
* @Given /^The authentication plugin "([^"]*)" is enabled$/
|
||||
* @Given the authentication plugin :name is enabled
|
||||
*/
|
||||
public function theAuthenticationPluginIsEnabled($auth) {
|
||||
set_config('auth', $auth);
|
||||
public function the_authentication_plugin_is_enabled($name) {
|
||||
set_config('auth', $name);
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^I am on Outage Management Page$/
|
||||
*/
|
||||
public function i_am_on_outage_management_page() {
|
||||
$this->getSession()->visit($this->locate_path('/auth/outage/manage.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^I am an administrator$/
|
||||
*/
|
||||
public function i_am_an_administrator() {
|
||||
// Visit login page.
|
||||
$this->getSession()->visit($this->locate_path('login/index.php'));
|
||||
|
||||
// Enter username and password.
|
||||
$this->execute('behat_forms::i_set_the_field_to', array('Username', $this->escape('admin')));
|
||||
$this->execute('behat_forms::i_set_the_field_to', array('Password', $this->escape('admin')));
|
||||
|
||||
// Press log in button, no need to check for exceptions as it will checked after this step execution.
|
||||
$this->execute('behat_forms::press_button', get_string('login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^I visit the Create Outage Page$/
|
||||
*/
|
||||
public function i_visit_the_create_outage_page() {
|
||||
$this->getSession()->visit($this->locate_path('/auth/outage/new.php'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,54 @@
|
||||
@auth @auth_outage @javascript
|
||||
@dev @auth @auth_outage @javascript
|
||||
Feature: Test changing the default settings.
|
||||
In order to check if I can set the default settings
|
||||
In order to easily create outages
|
||||
As an admin
|
||||
I need to go set the default values and check if they are using for new outages
|
||||
I need to configure the outage defaults
|
||||
|
||||
Background: Always login as admin and enable the auth_outage plugin.
|
||||
Given The authentication plugin "outage" is enabled
|
||||
And I log in as "admin"
|
||||
Rules:
|
||||
- Times should be expressed in minutes.
|
||||
|
||||
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. */ |
|
||||
Background:
|
||||
Given the authentication plugin "outage" is enabled
|
||||
And I am an administrator
|
||||
|
||||
Scenario: Check if I can save the default settings.
|
||||
When I navigate to "Default Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
And I set the following fields to these values:
|
||||
| s_auth_outage_default_autostart | 1 |
|
||||
| s_auth_outage_default_warning_duration | 15 |
|
||||
| s_auth_outage_default_duration | 30 |
|
||||
# | s_auth_outage_default_Title | My Behat Outage {start} |
|
||||
# | s_auth_outage_default_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."
|
||||
Then I should see "Changes saved"
|
||||
When I visit the Create Outage Page
|
||||
Then the following fields match these values:
|
||||
# | autostart | 1 |
|
||||
| warningduration[number] | 15 |
|
||||
| warningduration[timeunit] | 60 |
|
||||
| outageduration[number] | 30 |
|
||||
| outageduration[timeunit] | 60 |
|
||||
# | title | My Behat Outage {start} |
|
||||
# | description[text] | My outage <b>{stop}</b>. |
|
||||
|
||||
Scenario Outline: Check if I can save invalid values for default settings.
|
||||
When I navigate to "Default Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
And I set the following fields to these values:
|
||||
| s_auth_outage_default_autostart | 1 |
|
||||
| s_auth_outage_default_warning_duration | <warning> |
|
||||
| s_auth_outage_default_duration | <duration> |
|
||||
# | s_auth_outage_default_Title | <title> |
|
||||
# | s_auth_outage_default_description | <description> |
|
||||
| s_auth_outage_css | /* Some CSS. */ |
|
||||
And I press "Save changes"
|
||||
Then I should <seeornot> "Changes saved"
|
||||
|
||||
Examples:
|
||||
| warning | duration | title | description | seeornot |
|
||||
| 15 | 30 | My Title | My Description | see |
|
||||
| -1 | 30 | My Title | My Description | not see |
|
||||
| 15 | -1 | My Title | My Description | not see |
|
||||
| 15 | 30 | | My Description | not see |
|
||||
| 15 | 30 | My Title | | not see |
|
||||
|
||||
|
||||
20
tests/behat/manage_outages.feature
Normal file
20
tests/behat/manage_outages.feature
Normal file
@@ -0,0 +1,20 @@
|
||||
@auth @auth_outage @javascript
|
||||
Feature: Test the outage management functionality.
|
||||
In order to check if I can manage outages
|
||||
As an admin
|
||||
I need to create, edit, delete, clone and finish an outage.
|
||||
|
||||
Background: Always login as admin, enable the auth_outage plugin and go to the outage management page.
|
||||
Given The authentication plugin "outage" is enabled
|
||||
And I log in as "admin"
|
||||
|
||||
Scenario: Check if I can navigate to management page.
|
||||
Given I am on homepage
|
||||
When I navigate to "Manage" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
Then I should see "Create Outage"
|
||||
Then I should see "Planned outages"
|
||||
Then I should see "Outage history"
|
||||
|
||||
Scenario: Check if creating outages uses the configured defaults.
|
||||
Given I am on Outage Management Page
|
||||
When I click on "([^"]|\"*)" "<string>"
|
||||
Reference in New Issue
Block a user