1 Commits

Author SHA1 Message Date
Sasha Anastasi
e1a8dbc59f replace deprecated strftime function for Tōtara 17 2023-05-29 08:56:59 +12:00
28 changed files with 86 additions and 114 deletions

View File

@@ -65,13 +65,4 @@ class auth_plugin_outage extends auth_plugin_base {
public function user_login($username, $password) {
return false;
}
/**
* Returns true if the plugin supports the new login flow for MFA.
*
* @return bool True
*/
public static function supports_mfa(): bool {
return true;
}
}

View File

@@ -29,16 +29,18 @@
* @var stdClass $CFG
*/
define('MOODLE_INTERNAL', true);
defined('MOODLE_INTERNAL') || die(); // Make sniffer happy.
//
// This call is required by Moodle, but this script should have been called by config.php anyway.
// @codingStandardsIgnoreStart
require_once(__DIR__.'/../../config.php');
// @codingStandardsIgnoreEnd
// We need the CFG->dataroot, if not set yet this script is called too early in config.php file.
if (!isset($CFG->dataroot)) {
return;
}
// 1) Make sure we replace the configurations for behat as we have not ran 'lib/setup.php' yet.
if (!empty($CFG->behat_wwwroot) || !empty($CFG->behat_dataroot) || !empty($CFG->behat_prefix)) {
if (!empty($CFG->behat_wwwroot) or !empty($CFG->behat_dataroot) or !empty($CFG->behat_prefix)) {
require_once(__DIR__.'/../../lib/behat/lib.php');
behat_update_vars_for_process();
if (behat_is_test_site()) {

View File

@@ -129,7 +129,7 @@ class waitforit extends clibase {
return;
}
$time = date('Y-m-d H:i:s T', time());
$time = \totara_core\strftime::format('%F %T %Z');
printf("[%s] %s\n", $time, $message);
}

View File

@@ -23,6 +23,8 @@
namespace auth_outage\privacy;
use core_privacy\local\legacy_polyfill;
/**
* Privacy provider for the authentication manual.
*
@@ -32,6 +34,8 @@ namespace auth_outage\privacy;
class provider implements
\core_privacy\local\metadata\null_provider {
use legacy_polyfill;
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
@@ -41,7 +45,7 @@ class provider implements
*
* @return string
*/
public static function get_reason() : string {
public static function _get_reason() {
return 'privacy:no_data_reason';
}

View File

@@ -1,7 +0,0 @@
a {
font-size: 200%;
}
div {
background-image: url('/moodle/auth/outage/tests/local/controllers/fixtures/catalyst.png');
}

View File

@@ -1,7 +0,0 @@
a {
font-size: 200%;
}
div {
background-image: url(/moodle/auth/outage/tests/local/controllers/fixtures/catalyst.png);
}

View File

@@ -31,20 +31,18 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage;
use auth_outage\dml\outagedb;
use auth_outage\local\outage;
/**
* base_testcase class.
* auth_outage_base_testcase 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 base_testcase extends \advanced_testcase {
abstract class auth_outage_base_testcase extends advanced_testcase {
/**
* Checks PHPUnit version and calls the functions accordingly.
* @param string $exception Expected exception class.
@@ -73,7 +71,7 @@ abstract class base_testcase extends \advanced_testcase {
global $DB;
$guestrole = $DB->get_record('role', array('shortname' => 'guest'));
role_change_permission($guestrole->id, \context_system::instance(), 'auth/outage:viewinfo', CAP_PREVENT);
role_change_permission($guestrole->id, context_system::instance(), 'auth/outage:viewinfo', CAP_PREVENT);
$this->setGuestUser();
}

View File

@@ -23,8 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\calendar;
use auth_outage\calendar\calendar;
use auth_outage\local\outage;
/**
@@ -37,9 +36,8 @@ use auth_outage\local\outage;
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\calendar\calendar
*/
class calendar_test extends \advanced_testcase {
class auth_outage_calendar_test extends advanced_testcase {
/**
* @var outage|null The calendar entry owner.
*/

View File

@@ -23,8 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\dml;
use auth_outage\dml\outagedb;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
@@ -37,9 +36,8 @@ 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
* @covers \auth_outage\dml\outagedb
*/
class outagedb_test extends \auth_outage\base_testcase {
class auth_outage_outagedb_test extends auth_outage_base_testcase {
/**
* Creates an array of ids in from the given outages array.
* @param outage[] $outages An array of outages.

View File

@@ -23,8 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\dml;
use auth_outage\dml\outagedb;
use auth_outage\local\outage;
/**
@@ -37,9 +36,8 @@ use auth_outage\local\outage;
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\dml\outagedb
*/
class events_test extends \advanced_testcase {
class auth_outage_events_test extends advanced_testcase {
/**
* @var outage|null Outage used in the tests.
*/

View File

@@ -23,12 +23,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\form\outage;
use auth_outage\form\outage\delete;
use auth_outage\form\outage\edit;
use auth_outage\form\outage\finish;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../../base_testcase.php');
require_once(__DIR__.'/../base_testcase.php');
/**
* forms_test test class.
@@ -37,9 +38,8 @@ 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
* @covers \auth_outage\form\outage\edit
*/
class forms_test extends \auth_outage\base_testcase {
class auth_outage_forms_test extends auth_outage_base_testcase {
/**
* Create a delete form.
*/

View File

@@ -25,12 +25,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\dml;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../base_testcase.php');
require_once(__DIR__.'/base_testcase.php');
/**
* installation_test test class.
@@ -41,9 +39,8 @@ 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
* @covers \auth_outage\dml\outagedb
*/
class installation_test extends \auth_outage\base_testcase {
class auth_outage_installation_test extends auth_outage_base_testcase {
/**
* Checks if plugin cleans up data after uninstall.
*
@@ -67,7 +64,7 @@ class installation_test extends \auth_outage\base_testcase {
'description' => 'Description',
]);
ob_start();
outagedb::save($outage);
\auth_outage\dml\outagedb::save($outage);
$text = trim(ob_get_contents());
ob_end_clean();
self::assertStringContainsString('Update maintenance mode configuration', $text);
@@ -75,8 +72,8 @@ class installation_test extends \auth_outage\base_testcase {
// Uninstall plugin.
require_once($CFG->libdir.'/adminlib.php');
$progress = new \progress_trace_buffer(new \text_progress_trace(), false);
\core_plugin_manager::instance()->uninstall_plugin('auth_outage', $progress);
$progress = new progress_trace_buffer(new text_progress_trace(), false);
core_plugin_manager::instance()->uninstall_plugin('auth_outage', $progress);
$progress->finished();
self::assertStringContainsString('++ Success ++', $progress->get_buffer());

View File

@@ -23,11 +23,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/base_testcase.php');
require_once(__DIR__.'/../lib.php');
require_once(__DIR__.'/../../lib.php');
/**
* tests for lib.php
@@ -36,9 +34,8 @@ require_once(__DIR__.'/../lib.php');
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
* @copyright 2017 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers ::auth_outage_get_climaintenance_resource_file
*/
class lib_test extends base_testcase {
class auth_outage_lib_test extends auth_outage_base_testcase {
/**
* Test this plugin gets climaintenance resource file.
*/

View File

@@ -23,7 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\cli;
use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\create;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/cli_testcase.php');
@@ -35,9 +36,8 @@ 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
* @covers \auth_outage\local\cli\create
*/
class cli_test extends cli_testcase {
class auth_outage_cli_test extends auth_outage_cli_testcase {
/**
* Tests providing an unknown parameter.
*/
@@ -100,7 +100,7 @@ class cli_test extends cli_testcase {
// Disable all auth plugins.
set_config('auth', '');
\core\session\manager::gc(); // Remove stale sessions.
\core_plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
// Try to create an CLI object.
$this->set_expected_cli_exception(cli_exception::ERROR_PLUGIN_CONFIGURATION);
new create();

View File

@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* cli_testcase class.
* auth_outage_cli_testcase class.
*
* @package auth_outage
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
@@ -23,20 +23,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\cli;
use auth_outage\local\cli\clibase;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../../base_testcase.php');
/**
* cli_testcase class.
* auth_outage_cli_testcase 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 cli_testcase extends \auth_outage\base_testcase {
abstract class auth_outage_cli_testcase extends auth_outage_base_testcase {
/**
* Always enable the auth outage plugin, resets after test and set no parameters.
*/
@@ -49,7 +49,7 @@ abstract class cli_testcase extends \auth_outage\base_testcase {
// Enable auth plugins.
set_config('auth', 'outage');
\core\session\manager::gc(); // Remove stale sessions.
\core_plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
$this->set_parameters([]);
parent::setUp();

View File

@@ -23,9 +23,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\cli;
use auth_outage\dml\outagedb;
use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\create;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
@@ -38,9 +38,8 @@ 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
* @covers \auth_outage\local\cli\create
*/
class create_test extends cli_testcase {
class auth_outage_create_test extends auth_outage_cli_testcase {
/**
* Tests without any arguments.
*/

View File

@@ -23,9 +23,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\cli;
use auth_outage\dml\outagedb;
use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\finish;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
@@ -38,9 +38,8 @@ 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
* @covers \auth_outage\local\cli\finish
*/
class finish_test extends cli_testcase {
class auth_outage_finish_test extends auth_outage_cli_testcase {
/**
* Tests the constructor.
*/

View File

@@ -23,9 +23,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\cli;
use auth_outage\dml\outagedb;
use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\waitforit;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
@@ -38,9 +38,8 @@ 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
* @covers \auth_outage\local\cli\waitforit
*/
class waitforit_test extends cli_testcase {
class auth_outage_waitforit_test extends auth_outage_cli_testcase {
/**
* Tests the constructor.
*/

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,7 @@
a {
font-size: 200%;
}
div {
background-image: url('/moodle/auth/outage/tests/phpunit/local/controllers/fixtures/catalyst.png');
}

View File

@@ -0,0 +1,7 @@
a {
font-size: 200%;
}
div {
background-image: url(/moodle/auth/outage/tests/phpunit/local/controllers/fixtures/catalyst.png);
}

View File

@@ -23,10 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\controllers;
use auth_outage\local\controllers\infopage;
use auth_outage\local\outage;
use context_system;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../../base_testcase.php');
@@ -38,9 +36,8 @@ 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
* @covers \auth_outage\local\controllers\infopage
*/
class infopage_test extends \auth_outage\base_testcase {
class auth_outage_infopagecontroller_test extends auth_outage_base_testcase {
/**
* Tests the constructor.
*/

View File

@@ -23,10 +23,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local\controllers;
use auth_outage\local\controllers\maintenance_static_page;
use auth_outage\local\controllers\maintenance_static_page_io;
use auth_outage\local\controllers\maintenance_static_page_generator;
use auth_outage\task\update_static_page;
use DOMDocument;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../../base_testcase.php');
@@ -38,9 +38,8 @@ 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
* @covers \auth_outage\local\controllers\maintenance_static_page_generator
*/
class maintenance_static_page_test extends \auth_outage\base_testcase {
class auth_outage_maintenance_static_page_test extends auth_outage_base_testcase {
/**
* Test template file.
*/
@@ -122,7 +121,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
$page->generate();
// Check for css file.
self::assertFileExists($page->get_io()->get_resources_folder().'/53365950336b070c0b26ca50e7d0dad962c364e6.dGV4dC9wbGFpbg');
self::assertFileExists($page->get_io()->get_resources_folder().'/d8643101d96b093e642b15544e4d1f7815b5ba55.dGV4dC9wbGFpbg');
// Check for catalyst.png file referenced in url(..) of css.
self::assertFileExists($page->get_io()->get_resources_folder().'/ff7f7f87a26a908fc72930eaefb6b57306361d16.aW1hZ2UvcG5n');
@@ -140,7 +139,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
$page->generate();
// Check for css file.
self::assertFileExists($page->get_io()->get_resources_folder().'/e0b34925c1f939c247a4b50d6bf08c76088def39.dGV4dC9wbGFpbg');
self::assertFileExists($page->get_io()->get_resources_folder().'/9fe2374b03953e1949d54ab750be2d8706891c03.dGV4dC9wbGFpbg');
// Check for catalyst.png file referenced in url(..) of css.
self::assertFileExists($page->get_io()->get_resources_folder().'/ff7f7f87a26a908fc72930eaefb6b57306361d16.aW1hZ2UvcG5n');
@@ -232,11 +231,11 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
'<html><head><title>Title</title></head>'.
'<body><div style="'.$stylecontent.'">Content</div></body></html>';
// Temporarily disable debugging to prevent errors because file does not exist.
// Temporarily disable debugging to prevent errors because file does not exist
$debuglevel = $CFG->debug;
$CFG->debug = '';
$generated = $this->generated_page_html($html);
// Restore debugging level.
// Restore debugging level
$CFG->debug = $debuglevel;
$matches = $generator->get_url_from_inline_style($stylecontent);
if ($rewrite) {
@@ -325,7 +324,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
// We can still assert the contents really match, not just the hash.
$found = file_get_contents($file);
$expected = file_get_contents(__DIR__.'/fixtures/catalyst.png');
$expected = file_get_contents($CFG->dirroot.'/auth/outage/tests/phpunit/local/controllers/fixtures/catalyst.png');
self::assertSame($found, $expected);
}
@@ -337,7 +336,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
* @return string
*/
private function get_fixture_path($file) {
return (string)new \moodle_url('/auth/outage/tests/local/controllers/fixtures/'.$file);
return (string)new moodle_url('/auth/outage/tests/phpunit/local/controllers/fixtures/'.$file);
}
/**
@@ -363,10 +362,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
*/
public function test_get_url_for_file() {
$io = new maintenance_static_page_io();
self::assertStringContainsString(
'www.example.com/moodle/auth/outage/file.php?file=img.png',
$io->get_url_for_file('img.png')
);
self::assertStringContainsString('www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
}
/**

View File

@@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../base_testcase.php');
@@ -35,9 +35,8 @@ 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
* @covers \auth_outage\local\outage
*/
class outage_test extends \auth_outage\base_testcase {
class auth_outage_outage_test extends auth_outage_base_testcase {
/**
* Tests the constructor.
*/
@@ -55,7 +54,7 @@ class outage_test extends \auth_outage\base_testcase {
* Tests the constructor, giving data as an object.
*/
public function test_constructor_object() {
$obj = new \stdClass();
$obj = new stdClass();
$obj->id = 1;
$obj->autostart = true;
$obj->warntime = 2;

View File

@@ -23,11 +23,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_outage\local;
use auth_outage\dml\outagedb;
use auth_outage\local\outage;
use auth_outage\local\outagelib;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir.'/adminlib.php');
require_once(__DIR__.'/../base_testcase.php');
@@ -39,9 +40,8 @@ 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
* @covers \auth_outage\local\outagelib
*/
class outagelib_test extends \auth_outage\base_testcase {
class auth_outage_outagelib_test extends auth_outage_base_testcase {
/**
* Check if maintenance message is disabled as needed.
*/
@@ -594,6 +594,6 @@ EOT;
// Enable outage plugin so settings can be changed.
set_config('auth', 'outage');
\core\session\manager::gc(); // Remove stale sessions.
\core_plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
}
}