diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 8eb74f5..470c44e 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -23,13 +23,19 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['accesskey'] = 'Access key'; +$string['accesskey_help'] = 'Testers should pass the access key initially in the url parameters e.g. ?accesskey=xyz. This will then be stored in a cookie for 24 hours, during which the url parameter will not be necessary.
Note: the access key is in addition to any IP restrictions setup.'; +$string['allowedipsempty'] = 'No one will be blocked by IP because the list is empty. You can add your own IP address ({$a->ip}) and block all other IPs. IP blocking is in addition to access key blocking (if setup in outage)'; +$string['allowedipshasmyip'] = 'Your IP ({$a->ip}) is in the list and your IP will not be blocked out during an Outage.'; +$string['allowedipshasntmyip'] = 'Your IP ({$a->ip}) is not in the list and your IP will be blocked out during an outage.'; +$string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup to allow blocking via IP.
Please refer to our README.md file for more information.'; $string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.'; $string['autostart'] = 'Auto start maintenance mode.'; $string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.'; $string['builtinallowediplist'] = 'Builtin Allowed IP List'; $string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI'; -$string['clicreatehelp'] = 'Creates a new outage.'; $string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10"; +$string['clicreatehelp'] = 'Creates a new outage.'; $string['clicreateparamautostart'] = 'must be Y or N, sets if the outage automatically triggers maintenance mode.'; $string['clicreateparamblock'] = 'blocks until outage starts.'; $string['clicreateparamclone'] = 'clone another outage except for the start time.'; @@ -40,16 +46,28 @@ $string['clicreateparamonlyid'] = 'only outputs the new outage id, useful for sc $string['clicreateparamstart'] = 'in how many seconds should this outage start or unix time to start outage. Required.'; $string['clicreateparamtitle'] = 'the title of the outage.'; $string['clicreateparamwarn'] = 'how many seconds before it starts to display a warning.'; -$string['clifinishhelp'] = 'Finishes an ongoing outage.'; +$string['clierrorinvalidvalue'] = 'Invalid value for parameter: {$a->param}'; +$string['clierrorinvalidvalueemptystring'] = 'Param --{$a->param} must not be an empty string'; +$string['clierrorinvalidvaluenegativenumber'] = 'Param --{$a->param} must be a positive number'; +$string['clierrorinvalidvaluenotbool'] = 'Param --{$a->param} must be set to either Y or N'; +$string['clierrorinvalidvaluenotid'] = 'Param --{$a->param} must be an id number'; +$string['clierrorinvalidvaluenotnumber'] = 'Param --{$a->param} must be a number'; +$string['clierrorinvalidvaluenotstring'] = 'Param --{$a->param} must be a string'; +$string['clierrormissingparamaters'] = 'You must specify the start time, use --help for more information.'; +$string['clierroroutagechanged'] = 'Outage was changed while waiting.'; +$string['clierroroutageended'] = 'Outage has already ended.'; +$string['clierroroutagenotfound'] = 'Outage not found.'; $string['clifinishexamples'] = ''; +$string['clifinishhelp'] = 'Finishes an ongoing outage.'; $string['clifinishnotongoing'] = 'Outage is not ongoing.'; -$string['clifinishparamhelp'] = 'shows parameters help.'; $string['clifinishparamactive'] = 'finishes the currently active outage.'; +$string['clifinishparamhelp'] = 'shows parameters help.'; $string['clifinishparamoutageid'] = 'the id of the outage to finish.'; $string['cliinmaintenancemode'] = 'Moodle maintenance mode is on. Use "php admin/cli/maintenance.php --disable" to disable it before finishing the outage.'; +$string['clioutagecreated'] = 'Outage created, id: {$a->id}'; $string['cliwaitforiterroridxoractive'] = 'You must use --outageid=# or --active parameter but not both.'; -$string['cliwaitforithelp'] = 'Waits until an outage starts.'; $string['cliwaitforitexamples'] = ''; +$string['cliwaitforithelp'] = 'Waits until an outage starts.'; $string['cliwaitforitoutagestarted'] = 'Outage started!'; $string['cliwaitforitoutagestartingin'] = 'Outage starting in {$a->countdown}.'; $string['cliwaitforitparamactive'] = 'wait for the currently active outage.'; @@ -57,39 +75,27 @@ $string['cliwaitforitparamhelp'] = 'shows parameters help.'; $string['cliwaitforitparamoutageid'] = 'the id of the outage to wait until it starts.'; $string['cliwaitforitparamsleep'] = 'maximum amount of seconds before status output.'; $string['cliwaitforitparamverbose'] = 'enable verbose mode.'; -$string['clierrorinvalidvalue'] = 'Invalid value for parameter: {$a->param}'; -$string['clierrorinvalidvaluenotid'] = 'Param --{$a->param} must be an id number'; -$string['clierrorinvalidvaluenotbool'] = 'Param --{$a->param} must be set to either Y or N'; -$string['clierrorinvalidvaluenotnumber'] = 'Param --{$a->param} must be a number'; -$string['clierrorinvalidvaluenegativenumber'] = 'Param --{$a->param} must be a positive number'; -$string['clierrorinvalidvaluenotstring'] = 'Param --{$a->param} must be a string'; -$string['clierrorinvalidvalueemptystring'] = 'Param --{$a->param} must not be an empty string'; -$string['clierrormissingparamaters'] = 'You must specify the start time, use --help for more information.'; -$string['clierroroutagechanged'] = 'Outage was changed while waiting.'; -$string['clierroroutageended'] = 'Outage has already ended.'; -$string['clierroroutagenotfound'] = 'Outage not found.'; -$string['clioutagecreated'] = 'Outage created, id: {$a->id}'; $string['clone'] = 'Clone'; -$string['configurationwarning'] = 'The outage plugin is not properly configured, please refer to README.md for more information.'; $string['configurationdisabled'] = 'The authentication plugin \'Outage\' is disabled. Please enable it in the site administration it and try again.'; $string['configurationinaccessiblewwwroot'] = 'Could not access {$a->wwwroot} from the server, creation of outages may fail.'; +$string['configurationwarning'] = 'The outage plugin is not properly configured, please refer to README.md for more information.'; $string['datetimeformat'] = '%a %d %h %Y at %I:%M%P %Z'; +$string['defaultdescription'] = 'Description'; +$string['defaultdescriptiondescription'] = 'Default warning message for outages. Use {{start}} and {{stop}} placeholders as required.'; +$string['defaultdescriptionvalue'] = 'There is maintenance scheduled from {{start}} to {{stop}} and our system will not be available during that time.'; $string['defaultlayoutcss'] = 'Layout CSS'; $string['defaultlayoutcssdescription'] = 'This CSS code can be used to override the Outage Warning Bar CSS.'; $string['defaultoutageautostart'] = 'Outage auto start'; $string['defaultoutageautostartdescription'] = 'If the outage should automatically trigger maintenance mode once it starts, locking down the whole site.'; $string['defaultoutageduration'] = 'Outage duration'; $string['defaultoutagedurationdescription'] = 'Default duration (in minutes) of an outage.'; -$string['defaultwarningduration'] = 'Warning duration'; -$string['defaultwarningdurationdescription'] = 'Default warning time (in minutes) for outages.'; $string['defaulttime'] = 'Default time'; $string['defaulttimedescription'] = 'The default time for the next outage, expressed in natural language eg "next Thursday 7pm". See PHP relative dates'; $string['defaulttitle'] = 'Title'; $string['defaulttitledescription'] = 'Default title for outages. Use {{start}} and {{stop}} placeholders as required.'; $string['defaulttitlevalue'] = 'System down from {{start}} for {{duration}}'; -$string['defaultdescription'] = 'Description'; -$string['defaultdescriptiondescription'] = 'Default warning message for outages. Use {{start}} and {{stop}} placeholders as required.'; -$string['defaultdescriptionvalue'] = 'There is maintenance scheduled from {{start}} to {{stop}} and our system will not be available during that time.'; +$string['defaultwarningduration'] = 'Warning duration'; +$string['defaultwarningdurationdescription'] = 'Default warning time (in minutes) for outages.'; $string['description'] = 'Public Description'; $string['description_help'] = 'A full description of the outage, publicly visible by all users.'; $string['finish'] = 'Finish'; @@ -97,29 +103,24 @@ $string['info15secondsbefore'] = '15 seconds before'; $string['infoendofoutage'] = 'end of outage'; $string['infofrom'] = 'From:'; $string['infohidewarning'] = 'no warning bar'; -$string['infountil'] = 'Until:'; +$string['infopagestaticgenerated'] = 'This warning was generated on {$a->time}.'; $string['infostart'] = 'start'; $string['infostartofwarning'] = 'start of warning'; $string['infostaticpage'] = 'static page'; -$string['infopagestaticgenerated'] = 'This warning was generated on {$a->time}.'; +$string['infountil'] = 'Until:'; $string['ips_combine'] = 'The IPs listed above will be combined with the IPs listed below.'; -$string['allowedipsempty'] = 'No one will be blocked by IP because the list is empty. You can add your own IP address ({$a->ip}) and block all other IPs. IP blocking is in addition to access key blocking (if setup in outage)'; -$string['allowedipshasmyip'] = 'Your IP ({$a->ip}) is in the list and your IP will not be blocked out during an Outage.'; -$string['allowedipshasntmyip'] = 'Your IP ({$a->ip}) is not in the list and your IP will be blocked out during an outage.'; -$string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup to allow blocking via IP.
Please refer to our README.md file for more information.'; $string['logformaintmodeconfig'] = 'Update maintenance mode configuration.'; $string['logformaintmodeconfigcomplete'] = 'Updating maintenance mode configuration complete.'; -$string['menusettings'] = 'Settings'; $string['menumanage'] = 'Manage outages'; +$string['menusettings'] = 'Settings'; $string['messageoutagebackonline'] = 'We are back online!'; $string['messageoutagebackonlinedescription'] = 'You may resume browsing safely.'; $string['messageoutageongoing'] = 'Back online at {$a->stop}.'; $string['messageoutagewarning'] = 'Shutting down in {{countdown}}'; $string['na'] = 'n/a'; $string['notfound'] = 'No outages found.'; +$string['outage:updatenotify'] = ''; $string['outage:viewinfo'] = 'View outage info'; -$string['outageedit'] = 'Edit outage'; -$string['outageeditcrumb'] = 'Edit'; $string['outageclone'] = 'Clone outage'; $string['outageclonecrumb'] = 'Clone'; $string['outagecreate'] = 'Create outage'; @@ -127,13 +128,14 @@ $string['outagecreatecrumb'] = 'Create'; $string['outagedelete'] = 'Delete outage'; $string['outagedeletewarning'] = 'You are about to permanently delete the outage below. This cannot be undone.'; $string['outageduration'] = 'Outage duration'; -$string['outagedurationerrorinvalid'] = 'Outage duration must be positive.'; $string['outageduration_help'] = 'How long the outage lasts after it starts.'; +$string['outagedurationerrorinvalid'] = 'Outage duration must be positive.'; +$string['outageedit'] = 'Edit outage'; +$string['outageeditcrumb'] = 'Edit'; $string['outagefinish'] = 'Finish outage'; $string['outagefinishwarning'] = 'You are about to mark this outage as finished. The system will be immediately back online.'; $string['outageslistfuture'] = 'Planned outages'; $string['outageslistpast'] = 'Outage history'; -$string['outage:updatenotify'] = ''; $string['pluginname'] = 'Outage manager'; $string['removeselectors'] = 'Remove selectors'; $string['removeselectorsdescription'] = 'CSS selectors to remove when rendering a static themed maintenance page. One selector per line.'; @@ -144,28 +146,26 @@ $string['settingssectionplugindescription'] = 'General outage management plugin $string['starttime'] = 'Start date and time'; $string['starttime_help'] = 'At which date and time the outage starts, preventing general access to the system.'; $string['tableheaderduration'] = 'Duration'; -$string['tableheaderdurationplanned'] = 'Planned duration'; $string['tableheaderdurationactual'] = 'Actual duration'; -$string['tableheaderstarttime'] = 'Starts on'; +$string['tableheaderdurationplanned'] = 'Planned duration'; $string['tableheaderstartedtime'] = 'Started on'; -$string['tableheaderwarnbefore'] = 'Warns before'; +$string['tableheaderstarttime'] = 'Starts on'; $string['tableheadertitle'] = 'Title'; +$string['tableheaderwarnbefore'] = 'Warns before'; $string['tablestarttimefutureformat'] = '{$a->absolute}
In {$a->relative}'; $string['tablestarttimepastformat'] = '{$a->absolute}
{$a->relative} ago'; $string['taskupdatestaticpage'] = 'Update static outage page'; $string['textplaceholdershint'] = 'You can use {{start}}, {{stop}} and {{duration}} as placeholders on the title and description.'; -$string['titleerrorinvalid'] = 'Title cannot be left blank.'; -$string['titleerrortoolong'] = 'Title cannot have more than {$a} characters.'; $string['title'] = 'Title'; $string['title_help'] = 'A short title to for this outage. It will be displayed on the warning bar and on the calendar.'; -$string['warningdurationerrorinvalid'] = 'Warning duration must be positive.'; -$string['warningduration'] = 'Warning duration'; -$string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.'; -$string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.
Untick "Auto start maintenance mode" if you want to prevent this.'; -$string['accesskey'] = 'Access key'; -$string['accesskey_help'] = 'Testers should pass the access key initially in the url parameters e.g. ?accesskey=xyz. This will then be stored in a cookie for 24 hours, during which the url parameter will not be necessary.
Note: the access key is in addition to any IP restrictions setup.'; +$string['titleerrorinvalid'] = 'Title cannot be left blank.'; +$string['titleerrortoolong'] = 'Title cannot have more than {$a} characters.'; $string['useaccesskey'] = 'Use access key'; $string['useaccesskey:desc'] = 'Require testers to access site during outage by providing the access key below'; +$string['warningduration'] = 'Warning duration'; +$string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.'; +$string['warningdurationerrorinvalid'] = 'Warning duration must be positive.'; +$string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.
Untick "Auto start maintenance mode" if you want to prevent this.'; /* * Privacy provider (GDPR) diff --git a/tests/calendar/calendar_test.php b/tests/calendar/calendar_test.php index 9481256..48c6a5f 100644 --- a/tests/calendar/calendar_test.php +++ b/tests/calendar/calendar_test.php @@ -39,7 +39,7 @@ use auth_outage\local\outage; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @covers \auth_outage\calendar\calendar */ -class calendar_test extends \advanced_testcase { +final class calendar_test extends \advanced_testcase { /** * @var outage|null The calendar entry owner. */ @@ -48,7 +48,7 @@ class calendar_test extends \advanced_testcase { /** * Creates an outage and checks if its in the calendar. */ - public function test_create() { + public function test_create(): void { $this->resetAfterTest(true); self::setAdminUser(); @@ -69,7 +69,7 @@ class calendar_test extends \advanced_testcase { /** * Updates an outage and checks the calendar. */ - public function test_update() { + public function test_update(): void { $this->resetAfterTest(true); self::setAdminUser(); @@ -93,7 +93,7 @@ class calendar_test extends \advanced_testcase { /** * Deletes an outage and checks the calendar. */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(true); self::setAdminUser(); @@ -118,7 +118,7 @@ class calendar_test extends \advanced_testcase { /** * Try to update a non existing outage. */ - public function test_update_notfound() { + public function test_update_notfound(): void { $this->resetAfterTest(true); self::setAdminUser(); @@ -141,7 +141,7 @@ class calendar_test extends \advanced_testcase { /** * Try to delete a non existing outage. */ - public function test_delete_notfound() { + public function test_delete_notfound(): void { $this->resetAfterTest(true); self::setAdminUser(); diff --git a/tests/dml/events_test.php b/tests/dml/events_test.php index d2a9d85..3ee83ea 100644 --- a/tests/dml/events_test.php +++ b/tests/dml/events_test.php @@ -39,7 +39,7 @@ use auth_outage\local\outage; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @covers \auth_outage\dml\outagedb */ -class events_test extends \advanced_testcase { +final class events_test extends \advanced_testcase { /** * @var outage|null Outage used in the tests. */ @@ -54,7 +54,7 @@ class events_test extends \advanced_testcase { * Saves an outage and check if the event was created. * @return array With the outage id and the event id. */ - public function test_save() { + public function test_save(): void { global $DB; self::setAdminUser(); $this->resetAfterTest(true); @@ -86,7 +86,7 @@ class events_test extends \advanced_testcase { /** * Updates an outage and checks if the event was updated. */ - public function test_update() { + public function test_update(): void { global $DB; self::setAdminUser(); @@ -124,7 +124,7 @@ class events_test extends \advanced_testcase { /** * Deletes an outage and checks if the event was deleted. */ - public function test_delete() { + public function test_delete(): void { global $DB; self::setAdminUser(); diff --git a/tests/dml/installation_test.php b/tests/dml/installation_test.php index 3657dfc..0021f99 100644 --- a/tests/dml/installation_test.php +++ b/tests/dml/installation_test.php @@ -43,13 +43,13 @@ require_once(__DIR__ . '/../base_testcase.php'); * @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 { +final class installation_test extends \auth_outage\base_testcase { /** * Checks if plugin cleans up data after uninstall. * * See Issue #57. */ - public function test_uninstall() { + public function test_uninstall(): void { global $CFG, $DB; $this->resetAfterTest(); diff --git a/tests/dml/outagedb_test.php b/tests/dml/outagedb_test.php index 9f0e478..2f102bd 100644 --- a/tests/dml/outagedb_test.php +++ b/tests/dml/outagedb_test.php @@ -39,7 +39,7 @@ require_once(__DIR__ . '/../base_testcase.php'); * @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 { +final class 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. @@ -88,7 +88,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Make sure we can save and update. */ - public function test_save() { + public function test_save(): void { $this->resetAfterTest(true); // Save new outage. $id = outagedb::save($this->createoutage(1)); @@ -101,7 +101,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Create a few outages, fetch them and check if fields match. */ - public function test_saved_fields() { + public function test_saved_fields(): void { $this->resetAfterTest(true); for ($i = 0; $i < 4; $i++) { $expected = $this->createoutage($i); @@ -119,7 +119,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Make sure we can get existing entries and null if not found. */ - public function test_getbyid() { + public function test_getbyid(): void { $this->resetAfterTest(true); // Create something. $id = outagedb::save($this->createoutage(1)); @@ -136,7 +136,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Make sure we can delete stuff. */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(true); // Create something. $id = outagedb::save($this->createoutage(1)); @@ -149,7 +149,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Make sure we can finish outages. */ - public function test_finish() { + public function test_finish(): void { $now = time(); $this->resetAfterTest(true); // Create it. @@ -169,7 +169,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Make sure getall brings all entries. */ - public function test_getall() { + public function test_getall(): void { $this->resetAfterTest(true); $amount = 10; // Should start empty. @@ -186,7 +186,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Perform some tests on the data itself, checking values after inserted and updated. */ - public function test_basiccrud() { + public function test_basiccrud(): void { $this->resetAfterTest(true); // Create some outages. @@ -228,7 +228,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_active() method. */ - public function test_getactive() { + public function test_getactive(): void { $this->resetAfterTest(true); // Have a consistent time for now (no seconds variation), helps debugging. @@ -288,7 +288,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_all_unended() method. */ - public function test_getallunended() { + public function test_getallunended(): void { $this->resetAfterTest(true); // Have a consistent time for now (no seconds variation), helps debugging. @@ -363,7 +363,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_all_ended() method. */ - public function test_getallended() { + public function test_getallended(): void { $this->resetAfterTest(true); // Have a consistent time for now (no seconds variation), helps debugging. @@ -413,7 +413,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_by_id() with an invalid parameter. */ - public function test_getbyid_invalid() { + public function test_getbyid_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_by_id(-1); @@ -422,7 +422,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::delete() with an invalid parameter. */ - public function test_delete_invalid() { + public function test_delete_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::delete(-1); @@ -431,7 +431,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_active() with an invalid parameter. */ - public function test_getactive_invalid() { + public function test_getactive_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_active(-1); @@ -440,7 +440,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_all_unended() with an invalid parameter. */ - public function test_getallunended_invalid() { + public function test_getallunended_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_all_unended(-1); @@ -449,7 +449,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Checks we can execute outagedb::get_all_unended() without parameters (now). */ - public function test_getallunended_now() { + public function test_getallunended_now(): void { $this->resetAfterTest(true); self::assertEmpty(outagedb::get_all_unended()); } @@ -457,7 +457,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_all_ended() with an invalid parameter. */ - public function test_getallended_invalid() { + public function test_getallended_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_all_ended(-1); @@ -466,7 +466,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Checks we can execute outagedb::test_getallended_now() without parameters (now). */ - public function test_getallended_now() { + public function test_getallended_now(): void { $this->resetAfterTest(true); self::assertEmpty(outagedb::get_all_ended()); } @@ -474,7 +474,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::finish() with an invalid parameter. */ - public function test_finish_invalid() { + public function test_finish_invalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::finish(1, -1); @@ -483,7 +483,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::finish() with a non existing outage. */ - public function test_finish_now_notfound() { + public function test_finish_now_notfound(): void { $this->resetAfterTest(true); outagedb::finish(1); self::assertCount(1, $this->getDebuggingMessages()); @@ -493,7 +493,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Try to finish not ongoing outages. */ - public function test_finish_notongoing() { + public function test_finish_notongoing(): void { $this->resetAfterTest(true); $time = time(); $outage = new outage([ @@ -515,7 +515,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_next_starting() with an invalid parameter. */ - public function test_getnextstartinginvalid() { + public function test_getnextstartinginvalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_next_starting(-1); @@ -524,7 +524,7 @@ class outagedb_test extends \auth_outage\base_testcase { /** * Tests the outagedb::get_next_autostarting() with an invalid parameter. */ - public function test_getnextautostartinginvalid() { + public function test_getnextautostartinginvalid(): void { $this->resetAfterTest(true); $this->set_expected_exception('coding_exception'); outagedb::get_next_autostarting(-1); diff --git a/tests/form/outage/forms_test.php b/tests/form/outage/forms_test.php index 4e63de7..a43cde7 100644 --- a/tests/form/outage/forms_test.php +++ b/tests/form/outage/forms_test.php @@ -39,25 +39,25 @@ require_once(__DIR__ . '/../../base_testcase.php'); * @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 { +final class forms_test extends \auth_outage\base_testcase { /** * Create a delete form. */ - public function test_delete() { + public function test_delete(): void { new delete(); } /** * Create a finish form. */ - public function test_finish() { + public function test_finish(): void { new finish(); } /** * Mock some data and check values. */ - public function test_edit_valid() { + public function test_edit_valid(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -78,7 +78,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check invalid warning duration. */ - public function test_edit_invalid_warning() { + public function test_edit_invalid_warning(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -93,7 +93,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check invalid outage duration. */ - public function test_edit_invalid_duration() { + public function test_edit_invalid_duration(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -107,7 +107,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check invalid title (empty). */ - public function test_edit_invalid_title() { + public function test_edit_invalid_title(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -121,7 +121,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check invalid title (too long). */ - public function test_edit_invalid_title_toolong() { + public function test_edit_invalid_title_toolong(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -137,7 +137,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check invalid format for description. */ - public function test_edit_description_invalid_format() { + public function test_edit_description_invalid_format(): void { if ($this->skip_because_moodle_is_below_30('Moodle POST mocking was fixed in Moodle 30.')) { return; } @@ -153,7 +153,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check if set data works properly. */ - public function test_setdata() { + public function test_setdata(): void { $outage = new outage([ 'autostart' => false, 'warntime' => time() - 60, @@ -169,7 +169,7 @@ class forms_test extends \auth_outage\base_testcase { /** * Check edit::set_data() with invalid parameter. */ - public function test_setdata_invalid() { + public function test_setdata_invalid(): void { $edit = new edit(); $this->set_expected_exception('coding_exception'); $edit->set_data(null); diff --git a/tests/lib_test.php b/tests/lib_test.php index 65e78f1..360ff83 100644 --- a/tests/lib_test.php +++ b/tests/lib_test.php @@ -29,11 +29,11 @@ require_once(__DIR__ . '/../lib.php'); * @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 { +final class lib_test extends base_testcase { /** * Test this plugin gets climaintenance resource file. */ - public function test_auth_outage_get_climaintenance_resource_file_resolves_a_file() { + public function test_auth_outage_get_climaintenance_resource_file_resolves_a_file(): void { global $CFG; $dir = $CFG->dataroot . '/auth_outage/climaintenance'; mkdir($dir, 0777, true); @@ -55,7 +55,7 @@ class lib_test extends base_testcase { /** * Regression test for issue #104. */ - public function test_auth_outage_get_climaintenance_resource_file_resolves_a_file_with_symlink() { + public function test_auth_outage_get_climaintenance_resource_file_resolves_a_file_with_symlink(): void { global $CFG; // Create a file. @@ -87,7 +87,7 @@ class lib_test extends base_testcase { /** * Test this plugin gets climaintenance resource file and prevents path traversal attack. */ - public function test_auth_outage_get_climaintenance_resource_file_prevent_path_traversal() { + public function test_auth_outage_get_climaintenance_resource_file_prevent_path_traversal(): void { global $CFG; $dir = $CFG->dataroot . '/auth_outage/climaintenance'; diff --git a/tests/local/cli/cli_test.php b/tests/local/cli/cli_test.php index c3b12f6..8bbb62d 100644 --- a/tests/local/cli/cli_test.php +++ b/tests/local/cli/cli_test.php @@ -37,11 +37,11 @@ require_once(__DIR__ . '/cli_testcase.php'); * @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 { +final class cli_test extends cli_testcase { /** * Tests providing an unknown parameter. */ - public function test_invalidargumentparam() { + public function test_invalidargumentparam(): void { $this->set_parameters(['--aninvalidparameter']); $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_UNKNOWN); new create(); @@ -50,7 +50,7 @@ class cli_test extends cli_testcase { /** * Tests providing another unknow parameter (without --). */ - public function test_invalidargumentgiven() { + public function test_invalidargumentgiven(): void { $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_UNKNOWN); new create(['anotherinvalidparameter']); } @@ -58,7 +58,7 @@ class cli_test extends cli_testcase { /** * Tests setting reference times. */ - public function test_setreferencetime() { + public function test_setreferencetime(): void { $cli = new create(['start' => 0]); $cli->set_referencetime(1); $cli->set_referencetime(60 * 60 * 24 * 7); @@ -67,7 +67,7 @@ class cli_test extends cli_testcase { /** * Tests setting an invalid reference time. */ - public function test_setreferencetime_invalid() { + public function test_setreferencetime_invalid(): void { $this->set_parameters(['--start=60']); $cli = new create(); $this->set_expected_exception('coding_exception'); @@ -77,7 +77,7 @@ class cli_test extends cli_testcase { /** * Tests the help. */ - public function test_help() { + public function test_help(): void { $this->set_parameters(['-h']); $cli = new create(); $output = $this->execute($cli); @@ -88,7 +88,7 @@ class cli_test extends cli_testcase { /** * Tests the cli_exception. */ - public function test_exception() { + public function test_exception(): void { $this->set_expected_cli_exception(cli_exception::ERROR_UNDEFINED); throw new cli_exception('An CLI exception.'); } @@ -96,7 +96,7 @@ class cli_test extends cli_testcase { /** * Tests with the auth_outage plugin disabled. */ - public function test_authdisabled() { + public function test_authdisabled(): void { // Disable all auth plugins. set_config('auth', ''); \core\session\manager::gc(); // Remove stale sessions. diff --git a/tests/local/cli/create_test.php b/tests/local/cli/create_test.php index 0bb731b..8fa7133 100644 --- a/tests/local/cli/create_test.php +++ b/tests/local/cli/create_test.php @@ -40,11 +40,11 @@ require_once(__DIR__ . '/cli_testcase.php'); * @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 { +final class create_test extends cli_testcase { /** * Tests without any arguments. */ - public function test_noarguments() { + public function test_noarguments(): void { $cli = new create(); $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_MISSING); $this->execute($cli); @@ -53,7 +53,7 @@ class create_test extends cli_testcase { /** * Tests when the start time is not a valid number. */ - public function test_invalidparam_notanumber() { + public function test_invalidparam_notanumber(): void { $cli = new create(['start' => 'some day']); $cli->set_defaults([ 'warn' => 50, @@ -69,7 +69,7 @@ class create_test extends cli_testcase { /** * Tests when providing a negative start time. */ - public function test_invalidparam_negative() { + public function test_invalidparam_negative(): void { $cli = new create(['start' => -1]); $cli->set_defaults([ 'warn' => 50, @@ -85,7 +85,7 @@ class create_test extends cli_testcase { /** * Tests providing an empty title. */ - public function test_invalidparam_emptystring() { + public function test_invalidparam_emptystring(): void { $cli = new create(['start' => 0, 'title' => '']); $cli->set_defaults([ 'warn' => 50, @@ -101,7 +101,7 @@ class create_test extends cli_testcase { /** * Tests if not providing the title (it will be send as true). */ - public function test_invalidparam_notastring() { + public function test_invalidparam_notastring(): void { $cli = new create(['start' => 0, 'title' => true]); $cli->set_defaults([ 'warn' => 50, @@ -117,7 +117,7 @@ class create_test extends cli_testcase { /** * Tests the help. */ - public function test_help() { + public function test_help(): void { $this->set_parameters(['--help']); $cli = new create(); $output = $this->execute($cli); @@ -128,7 +128,7 @@ class create_test extends cli_testcase { /** * Tests the options and shortcuts. */ - public function test_options() { + public function test_options(): void { $cli = new create(); $options = $cli->generate_options(); @@ -145,7 +145,7 @@ class create_test extends cli_testcase { /** * Tests creating with all given options. */ - public function test_create_withoptions() { + public function test_create_withoptions(): void { $this->set_parameters([ '--autostart=true', '--warn=10', @@ -174,7 +174,7 @@ class create_test extends cli_testcase { /** * Tests creating with the onlyid parameter. */ - public function test_create_onlyid() { + public function test_create_onlyid(): void { $this->set_parameters([ '--onlyid', '--autostart=N', @@ -205,7 +205,7 @@ class create_test extends cli_testcase { /** * Tests creating using some default values. */ - public function test_create_withdefaults() { + public function test_create_withdefaults(): void { $this->set_parameters([ '--warn=100', '--start=50', @@ -238,7 +238,7 @@ class create_test extends cli_testcase { /** * Tests creating with clone. */ - public function test_create_withclone() { + public function test_create_withclone(): void { self::setAdminUser(); $now = time(); // Create the outage to clone. @@ -272,7 +272,7 @@ class create_test extends cli_testcase { /** * Tests creating with an invalid clone id. */ - public function test_create_withclone_invalid() { + public function test_create_withclone_invalid(): void { $this->set_parameters([ '--start=60', '--clone=-1', @@ -285,7 +285,7 @@ class create_test extends cli_testcase { /** * Tests creating with the block flag. */ - public function test_create_withblock() { + public function test_create_withblock(): void { // Not an extensive test in the blocking API, cliwaitforit tests should cover them deeper. $this->set_parameters([ '--autostart=N', @@ -307,7 +307,7 @@ class create_test extends cli_testcase { /** * Tests providing an invalid option as default. */ - public function test_setdefaults_extra() { + public function test_setdefaults_extra(): void { $cli = new create([]); $this->set_expected_exception('coding_exception'); $cli->set_defaults(['aninvalidparameter' => 'value']); @@ -316,7 +316,7 @@ class create_test extends cli_testcase { /** * Tests with an invalud autostart bool value. */ - public function test_invalid_bool() { + public function test_invalid_bool(): void { $this->set_parameters([ '--autostart=maybe', '--warn=60', diff --git a/tests/local/cli/finish_test.php b/tests/local/cli/finish_test.php index c8eb19f..844f248 100644 --- a/tests/local/cli/finish_test.php +++ b/tests/local/cli/finish_test.php @@ -40,11 +40,11 @@ require_once(__DIR__ . '/cli_testcase.php'); * @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 { +final class finish_test extends cli_testcase { /** * Tests the constructor. */ - public function test_constructor() { + public function test_constructor(): void { $cli = new finish(); self::assertNotNull($cli); } @@ -52,7 +52,7 @@ class finish_test extends cli_testcase { /** * Tests the generated options and shortcuts. */ - public function test_options() { + public function test_options(): void { $cli = new finish(); $options = $cli->generate_options(); @@ -69,7 +69,7 @@ class finish_test extends cli_testcase { /** * Tests the help. */ - public function test_help() { + public function test_help(): void { $this->set_parameters(['--help']); $cli = new finish(); $text = $this->execute($cli); @@ -80,7 +80,7 @@ class finish_test extends cli_testcase { /** * Tests if running without arguments. */ - public function test_noarguments() { + public function test_noarguments(): void { $cli = new finish(); $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_MISSING); $this->execute($cli); @@ -89,7 +89,7 @@ class finish_test extends cli_testcase { /** * Tests finishing an already ended outage. */ - public function test_endedoutage() { + public function test_endedoutage(): void { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ @@ -110,7 +110,7 @@ class finish_test extends cli_testcase { /** * Tests finishing an outage. */ - public function test_finish() { + public function test_finish(): void { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ @@ -130,7 +130,7 @@ class finish_test extends cli_testcase { /** * Tests finishing an active outage when it does not exists. */ - public function test_activenotfound() { + public function test_activenotfound(): void { self::setAdminUser(); $this->set_parameters(['-a']); $cli = new finish(); @@ -141,7 +141,7 @@ class finish_test extends cli_testcase { /** * Tests providing an invalid outage id. */ - public function test_invalidid() { + public function test_invalidid(): void { self::setAdminUser(); $this->set_parameters(['-id=theid']); $cli = new finish(); @@ -152,7 +152,7 @@ class finish_test extends cli_testcase { /** * Tests when the outage is not found. */ - public function test_idnotfound() { + public function test_idnotfound(): void { self::setAdminUser(); $this->set_parameters(['-id=99999']); $cli = new finish(); diff --git a/tests/local/cli/waitforit_test.php b/tests/local/cli/waitforit_test.php index 743b65a..350b79a 100644 --- a/tests/local/cli/waitforit_test.php +++ b/tests/local/cli/waitforit_test.php @@ -40,11 +40,11 @@ require_once(__DIR__ . '/cli_testcase.php'); * @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 { +final class waitforit_test extends cli_testcase { /** * Tests the constructor. */ - public function test_constructor() { + public function test_constructor(): void { $cli = new waitforit(); self::assertNotNull($cli); } @@ -52,7 +52,7 @@ class waitforit_test extends cli_testcase { /** * Tests the generated options. */ - public function test_generateoptions() { + public function test_generateoptions(): void { $cli = new waitforit(); $options = $cli->generate_options(); foreach (array_keys($options) as $k) { @@ -63,7 +63,7 @@ class waitforit_test extends cli_testcase { /** * Tests the generated shortcut options. */ - public function test_generateshortcuts() { + public function test_generateshortcuts(): void { $cli = new waitforit(); $options = $cli->generate_options(); $shorts = $cli->generate_shortcuts(); @@ -75,7 +75,7 @@ class waitforit_test extends cli_testcase { /** * Tests if help works. */ - public function test_help() { + public function test_help(): void { $this->set_parameters(['--help']); $cli = new waitforit(); $text = $this->execute($cli); @@ -86,7 +86,7 @@ class waitforit_test extends cli_testcase { /** * Checks if providing an outageid and active parameter. */ - public function test_bothparams() { + public function test_bothparams(): void { $this->set_parameters(['--outageid=1', '--active']); $cli = new waitforit(); $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_INVALID); @@ -96,7 +96,7 @@ class waitforit_test extends cli_testcase { /** * Tests with an invalid outage id */ - public function test_invalidoutageid() { + public function test_invalidoutageid(): void { $this->set_parameters(['-id=-1']); $cli = new waitforit(); $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_INVALID); @@ -106,7 +106,7 @@ class waitforit_test extends cli_testcase { /** * Tests with an active outage when it does not exists. */ - public function test_outagenotfound() { + public function test_outagenotfound(): void { $this->set_parameters(['-a']); $cli = new waitforit(); $this->set_expected_cli_exception(cli_exception::ERROR_OUTAGE_NOT_FOUND); @@ -116,7 +116,7 @@ class waitforit_test extends cli_testcase { /** * Tests with an outage that already ended. */ - public function test_endedoutage() { + public function test_endedoutage(): void { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ @@ -137,7 +137,7 @@ class waitforit_test extends cli_testcase { /** * Tests waiting for an existing active outage, verbose mode. */ - public function test_activeverbose() { + public function test_activeverbose(): void { self::setAdminUser(); $now = time(); outagedb::save(new outage([ diff --git a/tests/local/controllers/infopage_test.php b/tests/local/controllers/infopage_test.php index 41aa2b8..badb315 100644 --- a/tests/local/controllers/infopage_test.php +++ b/tests/local/controllers/infopage_test.php @@ -40,11 +40,11 @@ require_once(__DIR__ . '/../../base_testcase.php'); * @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 { +final class infopage_test extends \auth_outage\base_testcase { /** * Tests the constructor. */ - public function test_constructor() { + public function test_constructor(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); new infopage(); @@ -53,7 +53,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Tests the constructor with given parameters. */ - public function test_constructor_withparams() { + public function test_constructor_withparams(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); $_GET = ['id' => 1, 'static' => 'true']; @@ -63,7 +63,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Tests the constructor with different id and outage id. */ - public function test_constructor_idmismatch() { + public function test_constructor_idmismatch(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); $outage = $this->get_dummy_outage(); @@ -74,7 +74,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Tests the constructor with an invalid outage. */ - public function test_constructor_invalidoutage() { + public function test_constructor_invalidoutage(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); $this->set_expected_exception('coding_exception', 'Provided outage is not a valid outage object. (My outage)'); @@ -84,7 +84,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Checks the output of the info page. */ - public function test_output() { + public function test_output(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); $outage = $this->get_dummy_outage(); @@ -97,7 +97,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Checks the output of the info page. */ - public function test_output_without_permission() { + public function test_output_without_permission(): void { $this->revoke_info_page_permissions(); $this->assertFalse(has_capability('auth/outage:viewinfo', context_system::instance())); @@ -111,7 +111,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Checks the output of the info page. */ - public function test_output_without_permission_but_static() { + public function test_output_without_permission_but_static(): void { $this->revoke_info_page_permissions(); $this->assertFalse(has_capability('auth/outage:viewinfo', context_system::instance())); @@ -125,7 +125,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Checks the output of the info page. */ - public function test_output_with_forcelogin() { + public function test_output_with_forcelogin(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); set_config('forcelogin', true); @@ -140,7 +140,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Checks the output of the info page. */ - public function test_output_with_forcelogin_if_static() { + public function test_output_with_forcelogin_if_static(): void { $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); set_config('forcelogin', true); @@ -156,7 +156,7 @@ class infopage_test extends \auth_outage\base_testcase { /** * Tests the constructor enables SVG support. */ - public function test_svgicons_is_true() { + public function test_svgicons_is_true(): void { global $CFG; $this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance())); diff --git a/tests/local/controllers/maintenance_static_page_test.php b/tests/local/controllers/maintenance_static_page_test.php index 33d6a51..3155db3 100644 --- a/tests/local/controllers/maintenance_static_page_test.php +++ b/tests/local/controllers/maintenance_static_page_test.php @@ -40,11 +40,11 @@ require_once(__DIR__ . '/../../base_testcase.php'); * @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 { +final class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test template file. */ - public function test_templatefile() { + public function test_templatefile(): void { global $CFG; $page = maintenance_static_page::create_from_html(''); self::assertSame($CFG->dataroot . '/climaintenance.template.html', $page->get_io()->get_template_file()); @@ -58,7 +58,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test resources folder. */ - public function test_resourcesfolder() { + public function test_resourcesfolder(): void { global $CFG; $page = maintenance_static_page::create_from_html(''); self::assertSame($CFG->dataroot . '/auth_outage/climaintenance', $page->get_io()->get_resources_folder()); @@ -69,14 +69,14 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test create from outage. */ - public function test_createfromoutage() { + public function test_createfromoutage(): void { // How to fetch a page from PHPUnit environment? } /** * Test create from HTML. */ - public function test_createfromhtml() { + public function test_createfromhtml(): void { $html = "\nTitleContent"; $expected = "\nTitle" . "Content"; @@ -86,7 +86,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove script tags. */ - public function test_removescripttags() { + public function test_removescripttags(): void { $html = "\n" . 'Title' . 'Content'; @@ -99,7 +99,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove script tags. */ - public function test_updatelinkstylesheet() { + public function test_updatelinkstylesheet(): void { $localcsslink = $this->get_fixture_path_location('simple.css'); $externalcsslink = 'http://google.com/coolstuff.css'; $html = "\n" . @@ -115,7 +115,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update link style sheet urls. */ - public function test_updatelinkstylesheet_urls() { + public function test_updatelinkstylesheet_urls(): void { $localcsslink = $this->get_fixture_path_location('withurls.css'); $html = "\n" . 'Title' . @@ -135,7 +135,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update link style sheet urls quoted. */ - public function test_updatelinkstylesheet_urls_quoted() { + public function test_updatelinkstylesheet_urls_quoted(): void { $localcsslink = $this->get_fixture_path_location('withurls-quoted.css'); $html = "\n" . 'Title' . @@ -155,7 +155,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update link style sheet urls with sub dir. */ - public function test_updatelinkstylesheet_urls_subdir() { + public function test_updatelinkstylesheet_urls_subdir(): void { $localcsslink = $this->get_fixture_path_location('subdir/withurls-subdir.css'); $html = "\n" . 'Title' . @@ -175,7 +175,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update images to file.php style link. */ - public function test_updateimages() { + public function test_updateimages(): void { $localimglink = $this->get_fixture_path_location('catalyst.png'); $externalimglink = 'http://google.com/coolstyle.css'; $html = "\n" . @@ -191,7 +191,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update favicon to file.php style link. */ - public function test_updatelinkfavicon() { + public function test_updatelinkfavicon(): void { $link = $this->get_fixture_path_location('catalyst.png'); $html = "\n" . 'Title' . @@ -232,7 +232,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { * @param bool $rewrite Flag if URL should be rewritten * @throws coding_exception */ - public function test_update_inline_background_images($stylecontent, $rewrite) { + public function test_update_inline_background_images($stylecontent, $rewrite): void { global $CFG; $this->resetAfterTest(true); $generator = new maintenance_static_page_generator(new DOMDocument(), new maintenance_static_page_io()); @@ -260,7 +260,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test update preview path to file.php style link. */ - public function test_previewpath() { + public function test_previewpath(): void { $link = $this->get_fixture_path_location('catalyst.png'); $html = "\n" . 'Title' . @@ -291,7 +291,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Checks if we can create and execute a task to update outage pages. */ - public function test_tasks() { + public function test_tasks(): void { $this->resetAfterTest(true); $task = new update_static_page(); self::assertNotEmpty($task->get_name()); @@ -301,7 +301,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Tests updating the static page when there is no outage but the file existed before. */ - public function test_updatestaticpage_hasfile() { + public function test_updatestaticpage_hasfile(): void { global $CFG; $file = $CFG->dataroot . '/climaintenance.template.html'; touch($file); @@ -318,7 +318,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Tests created file. */ - public function test_createdfile() { + public function test_createdfile(): void { global $CFG; $link = $this->get_fixture_path_location('catalyst.png'); @@ -352,7 +352,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test saving empty string for template file. */ - public function test_invalid_string_saving_template_empty() { + public function test_invalid_string_saving_template_empty(): void { $io = new maintenance_static_page_io(); $this->set_expected_exception('coding_exception'); $io->save_template_file(''); @@ -361,7 +361,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test saving non string for template file. */ - public function test_invalid_string_saving_template_nostring() { + public function test_invalid_string_saving_template_nostring(): void { $io = new maintenance_static_page_io(); $this->set_expected_exception('coding_exception'); $io->save_template_file(50); @@ -370,7 +370,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test get url for file. */ - public function test_get_url_for_file() { + public function test_get_url_for_file(): void { $io = new maintenance_static_page_io(); self::assertStringContainsString( 'www.example.com/moodle/auth/outage/file.php?file=img.png', @@ -398,14 +398,14 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { * @param string $result expected result * @param string $url url to be checked */ - public function test_is_url($result, $url) { + public function test_is_url($result, $url): void { self::assertEquals($result, maintenance_static_page_io::is_url($url)); } /** * Test file get_data. */ - public function test_file_get_data() { + public function test_file_get_data(): void { $file = __DIR__ . '/fixtures/catalyst.png'; $found = maintenance_static_page_io::file_get_data($file); self::assertSame(file_get_contents($file), $found['contents']); @@ -415,7 +415,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test invalid file get_data. */ - public function test_file_get_data_invalidfile() { + public function test_file_get_data_invalidfile(): void { $found = maintenance_static_page_io::file_get_data(__DIR__ . '/fixtures/invalidfile'); self::assertSame('', $found['contents']); self::assertSame('unknown', $found['mime']); @@ -426,7 +426,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test invalid file get_data. */ - public function test_file_get_data_invalidfilename() { + public function test_file_get_data_invalidfilename(): void { $this->set_expected_exception('coding_exception'); maintenance_static_page_io::file_get_data(200); } @@ -436,7 +436,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { * We will use an external URL to test passing ignoresecurity inside of file_get_data works, * ideally in real code we should only be calling file_get_data with internal URLs. */ - public function test_file_get_data_curlsecurityblockedhosts() { + public function test_file_get_data_curlsecurityblockedhosts(): void { global $CFG, $USER; $testhtml = $this->getExternalTestFileUrl('/test.html'); @@ -467,7 +467,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector. */ - public function test_remove_css_selector() { + public function test_remove_css_selector(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -482,7 +482,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector id. */ - public function test_remove_css_selector_id() { + public function test_remove_css_selector_id(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -497,7 +497,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector with multi lines. */ - public function test_remove_css_selector_with_multiline() { + public function test_remove_css_selector_with_multiline(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -516,7 +516,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector needs trim. */ - public function test_remove_css_selector_needing_trim() { + public function test_remove_css_selector_needing_trim(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -535,7 +535,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector with empty line. */ - public function test_remove_css_selector_with_empty_line() { + public function test_remove_css_selector_with_empty_line(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -554,7 +554,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test remove css selector with invalid id. */ - public function test_remove_css_selector_with_invalid_id() { + public function test_remove_css_selector_with_invalid_id(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -569,7 +569,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test meta refresh 5 minutes. */ - public function test_meta_refresh_5minutes() { + public function test_meta_refresh_5minutes(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -629,7 +629,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase { * @param int $count Expected quantity of found URLs * @throws coding_exception */ - public function test_get_urls_from_stylesheet($filecontent, $count) { + public function test_get_urls_from_stylesheet($filecontent, $count): void { $this->resetAfterTest(true); $generator = new maintenance_static_page_generator(new DOMDocument(), new maintenance_static_page_io()); $matches = $generator->get_urls_from_stylesheet($filecontent); diff --git a/tests/local/outage_test.php b/tests/local/outage_test.php index cbfd8de..c550b0e 100644 --- a/tests/local/outage_test.php +++ b/tests/local/outage_test.php @@ -28,11 +28,11 @@ require_once(__DIR__ . '/../base_testcase.php'); * @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 { +final class outage_test extends \auth_outage\base_testcase { /** * Tests the constructor. */ - public function test_constructor() { + public function test_constructor(): void { $outage = new outage(); // Very important, this should never change. self::assertNull($outage->id, 'New empty outage can never have an id set.'); @@ -45,7 +45,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests the constructor, giving data as an object. */ - public function test_constructor_object() { + public function test_constructor_object(): void { $obj = new \stdClass(); $obj->id = 1; $obj->autostart = true; @@ -69,7 +69,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests the constructor with invalid data. */ - public function test_constructor_invalid() { + public function test_constructor_invalid(): void { $this->set_expected_exception('coding_exception'); new outage('My outage'); } @@ -77,7 +77,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests getting the stage considering the current time (now). */ - public function test_getstage_now() { + public function test_getstage_now(): void { $now = time(); // Make sure it is in the past. $outage = new outage([ @@ -93,7 +93,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests getting the stage providing an invalid time reference. */ - public function test_getstage_invalidtime() { + public function test_getstage_invalidtime(): void { $outage = new outage(); $this->set_expected_exception('coding_exception'); $outage->get_stage(-1); @@ -102,7 +102,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests is_ongoing() with different outage stages. */ - public function test_isongoing() { + public function test_isongoing(): void { $now = time(); // In the past. @@ -139,7 +139,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests is_active() with different outage stages. */ - public function test_isactive() { + public function test_isactive(): void { $now = time(); // In the past. @@ -186,7 +186,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests different outage stages. */ - public function test_stages() { + public function test_stages(): void { $now = time(); $outage = new outage([ @@ -261,7 +261,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests if getting title and description replaces the placeholders. */ - public function test_gettitle_getdescription() { + public function test_gettitle_getdescription(): void { $now = time(); $outage = new outage([ 'warntime' => $now - 50, @@ -282,7 +282,7 @@ class outage_test extends \auth_outage\base_testcase { /** * Tests getting the durations. */ - public function test_getdurations() { + public function test_getdurations(): void { $outage = new outage(['starttime' => 1000]); self::assertNull($outage->get_duration_actual()); diff --git a/tests/local/outagelib_test.php b/tests/local/outagelib_test.php index edb09df..092725a 100644 --- a/tests/local/outagelib_test.php +++ b/tests/local/outagelib_test.php @@ -32,11 +32,11 @@ require_once(__DIR__ . '/../base_testcase.php'); * @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 { +final class outagelib_test extends \auth_outage\base_testcase { /** * Check if maintenance message is disabled as needed. */ - public function test_maintenancemessage() { + public function test_maintenancemessage(): void { $this->resetAfterTest(true); static::setAdminUser(); @@ -64,7 +64,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if maintenance later is removed if no outage set. */ - public function test_maintenancelater_nonext() { + public function test_maintenancelater_nonext(): void { $this->resetAfterTest(true); set_config('maintenance_later', time() + (60 * 60 * 24 * 7)); // In 1 week. self::assertNotEmpty(get_config('moodle', 'maintenance_later')); @@ -75,7 +75,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check outagelib::inject() works as expected. */ - public function test_inject() { + public function test_inject(): void { global $OUTPUT; $this->resetAfterTest(true); @@ -111,7 +111,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check outagelib::inject() will not break the page if something goes wrong. */ - public function test_inject_broken() { + public function test_inject_broken(): void { $_GET = ['auth_outage_break_code' => '1']; outagelib::reset_injectcalled(); $header = outagelib::get_inject_code(); @@ -122,7 +122,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if injection works with preview. */ - public function test_inject_preview() { + public function test_inject_preview(): void { global $CFG; $this->resetAfterTest(true); self::setAdminUser(); @@ -152,7 +152,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if injection works with invalid preview without stopping the page. */ - public function test_inject_preview_notfound() { + public function test_inject_preview_notfound(): void { global $CFG; $_GET = ['auth_outage_preview' => '1']; @@ -165,7 +165,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Test injection with preview and delta. */ - public function test_inject_preview_withdelta() { + public function test_inject_preview_withdelta(): void { global $CFG; $this->resetAfterTest(true); self::setAdminUser(); @@ -193,7 +193,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Test injection without active outage. */ - public function test_inject_noactive() { + public function test_inject_noactive(): void { outagelib::reset_injectcalled(); outagelib::get_inject_code(); } @@ -201,7 +201,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if get config works without getting defaults. */ - public function test_get_config() { + public function test_get_config(): void { $this->resetAfterTest(true); $keys = [ 'css', @@ -231,7 +231,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check that config has key. */ - public function test_config_keys() { + public function test_config_keys(): void { $this->resetAfterTest(true); $keys = [ 'allowedips', @@ -252,7 +252,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if get config works getting defaults when needed. */ - public function test_get_config_invalid() { + public function test_get_config_invalid(): void { $this->resetAfterTest(true); // Set config with invalid values. set_config('allowedips', " \n", 'auth_outage'); @@ -274,7 +274,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Check if outagelib::inject() does not inject on admin/settings.php?section=additionalhtml */ - public function test_inject_settings() { + public function test_inject_settings(): void { global $CFG; $this->resetAfterTest(true); @@ -307,7 +307,7 @@ class outagelib_test extends \auth_outage\base_testcase { /** * Test create maintenance php code */ - public function test_createmaintenancephpcode() { + public function test_createmaintenancephpcode(): void { global $CFG; $CFG->cookiehttponly = false; @@ -387,7 +387,7 @@ EOT; * @param string $configkey The key of the config. * @dataProvider createmaintenancephpcode_withoutage_provider */ - public function test_createmaintenancephpcode_withoutage($configkey) { + public function test_createmaintenancephpcode_withoutage($configkey): void { global $CFG; $this->resetAfterTest(true); $CFG->cookiehttponly = false; @@ -481,7 +481,7 @@ EOT; /** * Test create maintenance php code without IPs or accesskey */ - public function test_createmaintenancephpcode_withoutips_or_accesskey() { + public function test_createmaintenancephpcode_withoutips_or_accesskey(): void { global $CFG; $this->resetAfterTest(true); @@ -507,7 +507,7 @@ EOT; /** * Test create maintenance php code without outage */ - public function test_createmaintenancephpcode_withoutoutage() { + public function test_createmaintenancephpcode_withoutoutage(): void { global $CFG; $file = $CFG->dataroot . '/climaintenance.php'; @@ -524,7 +524,7 @@ EOT; /** * Related to Issue #70: Creating ongoing outage does not trigger maintenance file creation. */ - public function test_preparenextoutage_notautostart() { + public function test_preparenextoutage_notautostart(): void { global $CFG; $this->create_outage(); @@ -539,7 +539,7 @@ EOT; /** * Regression Test - Issue #82: When changing the IP address list it should recreate the maintenance files. */ - public function test_when_we_change_allowed_ips_in_settings_it_updates_the_templates() { + public function test_when_we_change_allowed_ips_in_settings_it_updates_the_templates(): void { global $CFG; $this->create_outage(); @@ -557,7 +557,7 @@ EOT; /** * Problem detected while solving Issue #82. */ - public function test_when_we_change_remove_selectors_in_settings_it_updates_the_templates() { + public function test_when_we_change_remove_selectors_in_settings_it_updates_the_templates(): void { global $CFG; $this->create_outage(); @@ -575,7 +575,7 @@ EOT; /** * Related to Issue #72: IP Block still triggers cli maintenance mode even without autostart. */ - public function test_preparenextoutage_noautostarttrigger() { + public function test_preparenextoutage_noautostarttrigger(): void { global $CFG; $this->resetAfterTest(true); @@ -605,7 +605,7 @@ EOT; /** * Regression test for issue #85. */ - public function test_it_can_inject_in_settings_if_not_additional_html() { + public function test_it_can_inject_in_settings_if_not_additional_html(): void { global $CFG; $this->resetAfterTest(true); @@ -750,7 +750,7 @@ EOT; ?string $accesskey, ?string $accesskeytouse, array $expectedoutputs - ) { + ): void { global $CFG, $_SERVER, $_GET;