mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Fixed warnings, behat error and deprecated warnings.
This commit is contained in:
2
auth.php
2
auth.php
@@ -57,6 +57,8 @@ class auth_plugin_outage extends auth_plugin_base {
|
||||
|
||||
/**
|
||||
* Always returns false (password wrong or user does not exist).
|
||||
*
|
||||
* @inheritdoc PHPMD will not warn about unused parameters if overriding.
|
||||
* @param string $username Not used in this plugin.
|
||||
* @param string $password Not used in this plugin.
|
||||
* @return bool False
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* baseform class.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace auth_outage\form;
|
||||
|
||||
use moodleform;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* baseform class.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
abstract class baseform extends moodleform {
|
||||
/**
|
||||
* Validate the form. See MDL-56250.
|
||||
*
|
||||
* @param bool $validateonnosubmit optional, defaults to false. The default behaviour
|
||||
* is NOT to validate the form when a no submit button has been pressed.
|
||||
* pass true here to override this behaviour
|
||||
*
|
||||
* @return bool true if form data valid
|
||||
*/
|
||||
public function validate_defined_fields($validateonnosubmit = false) {
|
||||
// One validation NOT is enough (if mocking). See parent method.
|
||||
$mform =& $this->_form;
|
||||
if ($this->no_submit_button_pressed() && empty($validateonnosubmit)) {
|
||||
return false;
|
||||
}
|
||||
$internalval = $mform->validate();
|
||||
|
||||
$files = [];
|
||||
$fileval = $this->_validate_files($files);
|
||||
// Check draft files for validation and flag them if required files are not in draft area.
|
||||
$draftfilevalue = $this->validate_draft_files();
|
||||
|
||||
if ($fileval !== true && $draftfilevalue !== true) {
|
||||
$fileval = array_merge($fileval, $draftfilevalue);
|
||||
} else if ($draftfilevalue !== true) {
|
||||
$fileval = $draftfilevalue;
|
||||
} //default is file_val, so no need to assign.
|
||||
|
||||
if ($fileval !== true) {
|
||||
if (!empty($fileval)) {
|
||||
foreach ($fileval as $element => $msg) {
|
||||
$mform->setElementError($element, $msg);
|
||||
}
|
||||
}
|
||||
$fileval = false;
|
||||
}
|
||||
|
||||
$data = $mform->exportValues();
|
||||
$moodleval = $this->validation($data, $files);
|
||||
if ((is_array($moodleval) && count($moodleval) !== 0)) {
|
||||
// Non-empty array means errors.
|
||||
foreach ($moodleval as $element => $msg) {
|
||||
$mform->setElementError($element, $msg);
|
||||
}
|
||||
$moodleval = false;
|
||||
} else {
|
||||
// Anything else means validation ok.
|
||||
$moodleval = true;
|
||||
}
|
||||
|
||||
$validated = ($internalval and $moodleval and $fileval);
|
||||
return $validated;
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
namespace auth_outage\form\outage;
|
||||
|
||||
use auth_outage\form\baseform;
|
||||
use auth_outage\local\outage;
|
||||
use coding_exception;
|
||||
use moodleform;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -41,7 +41,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class edit extends baseform {
|
||||
class edit extends moodleform {
|
||||
/**
|
||||
* @var int Maximum number of characters for a title.
|
||||
*/
|
||||
|
||||
@@ -84,7 +84,7 @@ $string['infountil'] = 'Until:';
|
||||
$string['infostart'] = 'start';
|
||||
$string['infostartofwarning'] = 'start of warning';
|
||||
$string['infopagestaticgenerated'] = 'This warning was generated on {$a->time}.';
|
||||
$string['menudefaults'] = 'Default settings';
|
||||
$string['menusettings'] = 'Settings';
|
||||
$string['menumanage'] = 'Manage';
|
||||
$string['messageoutagebackonline'] = 'We are back online!';
|
||||
$string['messageoutagebackonlinedescription'] = 'You may resume browsing safely.';
|
||||
|
||||
@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||
if ($hassiteconfig && is_enabled_auth('outage')) {
|
||||
$defaults = outagelib::get_config_defaults();
|
||||
// Configure default settings page.
|
||||
$settings->visiblename = get_string('menudefaults', 'auth_outage');
|
||||
$settings->visiblename = get_string('menusettings', 'auth_outage');
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'auth_outage/default_autostart',
|
||||
get_string('defaultoutageautostart', 'auth_outage'),
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
use Behat\Behat\Context\Step\Given;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use Behat\Mink\Exception\ExpectationException;
|
||||
|
||||
@@ -40,6 +39,7 @@ require_once(__DIR__.'/../../../../lib/behat/behat_base.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class behat_auth_outage extends behat_base {
|
||||
/**
|
||||
@@ -69,10 +69,9 @@ class behat_auth_outage extends behat_base {
|
||||
/**
|
||||
* Logs into the system.
|
||||
* @Given /^I am an administrator$/
|
||||
* @return Given to execute.
|
||||
*/
|
||||
public function i_am_an_administrator() {
|
||||
return new Given('I log in as "admin"');
|
||||
$this->execute('behat_auth::i_log_in_as', ['admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,6 +299,7 @@ class behat_auth_outage extends behat_base {
|
||||
break;
|
||||
case 'stops':
|
||||
$seconds = $this->outage->stoptime - time();
|
||||
$seconds += 5; // Give it some extra time to pool the server.
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Invalid $what='.$what);
|
||||
|
||||
@@ -13,7 +13,7 @@ Feature: Change the default settings
|
||||
|
||||
|
||||
Scenario Outline: Check if I can save the default settings.
|
||||
When I navigate to "Default settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
When I navigate to "Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
And I set the following fields to these values:
|
||||
| s_auth_outage_default_autostart | <autostart> |
|
||||
| s_auth_outage_default_warning_duration[v] | <warning> |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@auth @auth_outage @javascript
|
||||
@dev @auth @auth_outage @javascript
|
||||
Feature: Warning bar
|
||||
In order alert users about an outage
|
||||
As any user
|
||||
@@ -31,26 +31,26 @@ Feature: Warning bar
|
||||
Then I should see "We are back online!" in the warning bar
|
||||
When I reload the page
|
||||
Then I should not see the warning bar
|
||||
|
||||
|
||||
Scenario Outline: Some stages should show its own warning message.
|
||||
Given there is a "<type>" outage
|
||||
When I am on homepage
|
||||
Then I should see "<see>" in the warning bar
|
||||
|
||||
Examples:
|
||||
| type | see |
|
||||
| warning | Shutting down in |
|
||||
| ongoing | Back online at |
|
||||
|
||||
|
||||
Scenario Outline: Some stages should not have a warning bar.
|
||||
Given there is a "<type>" outage
|
||||
When I am on homepage
|
||||
Then I should not see the warning bar
|
||||
|
||||
Examples:
|
||||
| type |
|
||||
| waiting |
|
||||
| finished |
|
||||
| stopped |
|
||||
#
|
||||
#
|
||||
# Scenario Outline: Some stages should show its own warning message.
|
||||
# Given there is a "<type>" outage
|
||||
# When I am on homepage
|
||||
# Then I should see "<see>" in the warning bar
|
||||
#
|
||||
# Examples:
|
||||
# | type | see |
|
||||
# | warning | Shutting down in |
|
||||
# | ongoing | Back online at |
|
||||
#
|
||||
#
|
||||
# Scenario Outline: Some stages should not have a warning bar.
|
||||
# Given there is a "<type>" outage
|
||||
# When I am on homepage
|
||||
# Then I should not see the warning bar
|
||||
#
|
||||
# Examples:
|
||||
# | type |
|
||||
# | waiting |
|
||||
# | finished |
|
||||
# | stopped |
|
||||
|
||||
@@ -40,6 +40,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
abstract class auth_outage_base_testcase extends advanced_testcase {
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ require_once(__DIR__.'/../base_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outagedb_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@ require_once(__DIR__.'/base_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class installation_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class cli_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ require_once(__DIR__.'/../../base_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
abstract class auth_outage_cli_testcase extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class create_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class finish_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class waitforit_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ require_once(__DIR__.'/../../base_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class infopagecontroller_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ require_once(__DIR__.'/../base_testcase.php');
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outage_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @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
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outagelib_test extends advanced_testcase {
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2016101800; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = '1.0.4'; // Human-readable release information.
|
||||
$plugin->requires = 2014051200; // Requires Moodle 2.7 or later. Moodle 2.9 or later recommended.
|
||||
$plugin->version = 2016110200; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = '1.0.5'; // Human-readable release information.
|
||||
$plugin->requires = 2014051200; // Requires Moodle 2.7 or later. Moodle 3.0 or later recommended.
|
||||
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
|
||||
Reference in New Issue
Block a user