From 5e0a3c015d668a224ba6114c62bc0124333d7c59 Mon Sep 17 00:00:00 2001 From: abhinavgandham Date: Tue, 20 Jan 2026 17:29:24 +1000 Subject: [PATCH] Modified unit tests to remove autostart, and quickstart guide and readme. --- QUICKGUIDE.md | 3 +- README.md | 1 - classes/dml/outagedb.php | 36 ------------------ classes/form/outage/edit.php | 2 - classes/local/cli/create.php | 8 ---- classes/local/outage.php | 8 ---- classes/local/outagelib.php | 3 +- db/install.xml | 3 +- db/upgrade.php | 11 +++++- edit.php | 1 - tests/base_testcase.php | 1 - tests/behat/behat_auth_outage.php | 6 --- tests/behat/default_settings.feature | 8 ++-- tests/calendar/calendar_test.php | 4 -- tests/dml/events_test.php | 3 -- tests/dml/installation_test.php | 3 +- tests/dml/outagedb_test.php | 15 +------- tests/form/outage/forms_test.php | 2 - tests/local/cli/create_test.php | 22 ----------- tests/local/cli/finish_test.php | 2 - tests/local/cli/waitforit_test.php | 4 -- tests/local/outage_test.php | 2 - tests/local/outagelib_test.php | 56 ---------------------------- 23 files changed, 18 insertions(+), 186 deletions(-) diff --git a/QUICKGUIDE.md b/QUICKGUIDE.md index 132a9a0..f02bf4f 100644 --- a/QUICKGUIDE.md +++ b/QUICKGUIDE.md @@ -98,9 +98,8 @@ Execute the commands from your Moodle instalation directory and leave the browse 1) Create an outage This command will create an outage starting in 30 seconds, with a warning period of 15 seconds. - It will automatically start (trigger maintenance mode). - `php auth/outage/cli/create.php -w=20 -s=30 --autostart=Y` + `php auth/outage/cli/create.php -w=20 -s=30` Refresh the page but you will not see anything yet. diff --git a/README.md b/README.md index ffb0a48..1db31a0 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,6 @@ Creates a new outage. -h, --help shows parameters help. -c, --clone clone another outage except for the start time. - -a, --autostart must be Y or N, sets if the outage automatically triggers maintenance mode. -w, --warn how many seconds before it starts to display a warning. -s, --start in how many seconds should this outage start or unix time to start outage. Required. -d, --duration how many seconds should the outage last. diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index 6d78b86..91d7943 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -100,11 +100,6 @@ class outagedb { $outage->modifiedby = $USER->id; $outage->lastmodified = time(); - // Setting autostart to false if the default autostart is configured to "Force off". - if (get_config('default_autostart', 'auth_outage') === '2') { - $outage->autostart = 0; - } - if ($outage->id === null) { // If new outage, set its creator. $outage->createdby = $USER->id; @@ -347,37 +342,6 @@ class outagedb { return (count($data) == 0) ? null : new outage(array_shift($data)); } - /** - * Gets the next outage which has not started yet and has the autostart flag set to true. - * @param null $time Timestamp reference for current time. - * @return outage|null The outage or null if not found. - * @throws coding_exception - */ - public static function get_next_autostarting($time = null) { - global $DB; - - if ($time === null) { - $time = time(); - } - if (!is_int($time) || ($time <= 0)) { - throw new coding_exception('$time must be null or a positive int.', $time); - } - - $data = $DB->get_records_select( - 'auth_outage', - '(:datetime <= starttime) AND (autostart = 1)', - ['datetime' => $time], - 'starttime ASC', - '*', - 0, - 1 - ); - - // Not using $DB->get_record_select instead because there is no 'limit' parameter. - // Allowing multiple records still raises an internal error. - return (count($data) == 0) ? null : new outage(array_shift($data)); - } - /** * Gets an ongoing outage (between start and stop time but not finished). * @param int|null $time Timestamp considered to check for outages, null for current date/time. diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php index 18622c1..20be069 100644 --- a/classes/form/outage/edit.php +++ b/classes/form/outage/edit.php @@ -136,7 +136,6 @@ class edit extends moodleform { } $outagedata = [ 'id' => ($data->id === 0) ? null : $data->id, - 'autostart' => (isset($data->autostart) && ($data->autostart == 1)), 'starttime' => $data->starttime, 'stoptime' => $data->starttime + $data->outageduration, 'warntime' => $data->starttime - $data->warningduration, @@ -161,7 +160,6 @@ class edit extends moodleform { if ($outage instanceof outage) { $this->_form->setDefaults([ 'id' => $outage->id, - 'autostart' => $outage->autostart, 'starttime' => $outage->starttime, 'outageduration' => $outage->get_duration_planned(), 'warningduration' => $outage->get_warning_duration(), diff --git a/classes/local/cli/create.php b/classes/local/cli/create.php index 62234f3..1e41169 100644 --- a/classes/local/cli/create.php +++ b/classes/local/cli/create.php @@ -43,7 +43,6 @@ class create extends clibase { return [ 'help' => false, 'clone' => null, - 'autostart' => null, 'warn' => null, 'start' => null, 'duration' => null, @@ -60,7 +59,6 @@ class create extends clibase { */ public function generate_shortcuts() { return [ - 'a' => 'autostart', 'b' => 'block', 'c' => 'clone', 'd' => 'duration', @@ -165,7 +163,6 @@ class create extends clibase { // an outage 47 years in advance. $start = $options['start'] > 1500000000 ? $options['start'] : $this->time + $options['start']; $outage = new outage([ - 'autostart' => $options['autostart'], 'warntime' => $start - $options['warn'], 'starttime' => $start, 'stoptime' => $start + $options['duration'], @@ -199,7 +196,6 @@ class create extends clibase { $outage = outagedb::get_by_id((int)$id); $this->set_defaults([ - 'autostart' => $outage->autostart, 'warn' => $outage->get_warning_duration(), 'duration' => $outage->get_duration_planned(), 'title' => $outage->title, @@ -222,10 +218,6 @@ class create extends clibase { $options[$param] = $this->merge_options_check_parameters_string_nonempty($options[$param], $param); } - foreach (['autostart'] as $param) { - $options[$param] = $this->merge_options_check_parameters_bool($options[$param], $param); - } - return $options; } diff --git a/classes/local/outage.php b/classes/local/outage.php index b64a309..42daa96 100644 --- a/classes/local/outage.php +++ b/classes/local/outage.php @@ -58,11 +58,6 @@ class outage { */ public $id = null; - /** - * @var bool|null Maintenance mode auto start flag. - */ - public $autostart = null; - /** * @var int|null Start Time timestamp. */ @@ -294,9 +289,6 @@ class outage { foreach ($fs as $f) { $this->$f = ($this->$f === null) ? null : (int)$this->$f; } - - // Adjust bool fields. - $this->autostart = ($this->autostart === null) ? null : (bool)$this->autostart; } /** diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index b23f99c..65826ad 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -173,7 +173,6 @@ class outagelib { 'allowedips' => '', 'css' => '', 'default_time' => '', - 'default_autostart' => '0', 'default_duration' => (string)(60 * 60), 'default_warning_duration' => (string)(60 * 60), 'default_title' => get_string('defaulttitlevalue', 'auth_outage'), @@ -223,7 +222,7 @@ class outagelib { * @param outage|null $outage Outage or null if no scheduled outage. */ private static function update_maintenance_later($outage) { - if (is_null($outage) || !$outage->autostart || get_config('default_autostart', 'auth_outage') === '2') { + if (is_null($outage)) { unset_config('maintenance_later'); } else { $message = get_config('moodle', 'maintenance_message'); diff --git a/db/install.xml b/db/install.xml index 8699ef9..1dcc2a1 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,5 +1,5 @@ - @@ -7,7 +7,6 @@ - diff --git a/db/upgrade.php b/db/upgrade.php index c1a0ba3..f4e7ea4 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -75,7 +75,16 @@ function xmldb_auth_outage_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2026011301, 'auth', 'outage'); } - if ($oldversion < 2026011302) { + if ($oldversion < 2024081902) { + // Getting the table auth_outage and target field to remove from the table. + $table = new xmldb_table('auth_outage'); + $field = new xmldb_field('autostart'); + + // Conditionally launch drop field autostart. + if ($dbman->field_exists($table, $field)) { + $dbman->drop_field($table, $field); + } + // Removing the default_autostart config as it is no longer used. unset_config('default_autostart', 'auth_outage'); diff --git a/edit.php b/edit.php index d3f34a3..841fe87 100644 --- a/edit.php +++ b/edit.php @@ -83,7 +83,6 @@ if ($clone) { } $outage = new outage([ - 'autostart' => $config->default_autostart, 'starttime' => $time, 'stoptime' => $time + $config->default_duration, 'warntime' => $time - $config->default_warning_duration, diff --git a/tests/base_testcase.php b/tests/base_testcase.php index 43802a2..2572fad 100644 --- a/tests/base_testcase.php +++ b/tests/base_testcase.php @@ -79,7 +79,6 @@ abstract class base_testcase extends \advanced_testcase { return new outage([ 'id' => 1, - 'autostart' => false, 'warntime' => $now - 100, 'starttime' => $now + 100, 'stoptime' => $now + 200, diff --git a/tests/behat/behat_auth_outage.php b/tests/behat/behat_auth_outage.php index d0ad2f0..8cf4024 100644 --- a/tests/behat/behat_auth_outage.php +++ b/tests/behat/behat_auth_outage.php @@ -88,7 +88,6 @@ class behat_auth_outage extends behat_base { */ public function there_is_a_outage($type) { $data = [ - 'autostart' => false, 'finished' => null, 'title' => 'Example of ' . $type . ' outage', 'description' => 'An outage: ' . $type, @@ -272,7 +271,6 @@ class behat_auth_outage extends behat_base { // Set defaults. $row = array_merge( [ - 'autostart' => 'no', 'warnbefore' => 60, 'startsin' => 0, 'stopsafter' => 60, @@ -282,16 +280,12 @@ class behat_auth_outage extends behat_base { ], $row ); - if (($row['autostart'] != 'yes') && ($row['autostart'] != 'no')) { - throw new Exception('autostart must be yes or no, found: ' . $row['autostart']); - } if ($row['finished'] == '') { $row['finished'] = null; } $starttime = $time + $row['startsin']; $this->outage = new outage([ - 'autostart' => ($row['autostart'] == 'yes'), 'warntime' => $starttime - $row['warnbefore'], 'starttime' => $starttime, 'stoptime' => $starttime + $row['stopsafter'], diff --git a/tests/behat/default_settings.feature b/tests/behat/default_settings.feature index 73d27dc..5e581cd 100644 --- a/tests/behat/default_settings.feature +++ b/tests/behat/default_settings.feature @@ -14,7 +14,6 @@ Feature: Change the default settings Scenario Outline: Check if I can save the default settings. When I navigate to "Plugins > Authentication > Outage manager > Settings" in site administration And I set the following fields to these values: - | s_auth_outage_default_autostart | | | s_auth_outage_default_warning_duration[v] | | | s_auth_outage_default_warning_duration[u] | 60 | | s_auth_outage_default_duration[v] | | @@ -26,7 +25,6 @@ Feature: Change the default settings Then I should see "Changes saved" When I visit the Create Outage Page Then the following fields match these values: - | autostart | | | warningduration[number] | | | warningduration[timeunit] | 60 | | outageduration[number] | | @@ -35,6 +33,6 @@ Feature: Change the default settings | description[text] | | Examples: - | autostart | warning | duration | title | description | css | - | 1 | 15 | 30 | An Outage | My outage until {stop}. | /* Some CSS. */ | - | 0 | 30 | 45 | My Behat Outage {start} | My outage with HTML. | /* More CSS. */ | + warning | duration | title | description | css | + 15 | 30 | An Outage | My outage until {stop}. | /* Some CSS. */ | + 30 | 45 | My Behat Outage {start} | My outage with HTML. | /* More CSS. */ | diff --git a/tests/calendar/calendar_test.php b/tests/calendar/calendar_test.php index 48c6a5f..c60773d 100644 --- a/tests/calendar/calendar_test.php +++ b/tests/calendar/calendar_test.php @@ -55,7 +55,6 @@ final class calendar_test extends \advanced_testcase { $time = time(); self::$outage = new outage([ 'id' => 1, - 'autostart' => false, 'warntime' => $time - 100, 'starttime' => $time, 'stoptime' => $time + (2 * 60 * 60), @@ -76,7 +75,6 @@ final class calendar_test extends \advanced_testcase { $time = time(); self::$outage = new outage([ 'id' => 1, - 'autostart' => false, 'warntime' => $time - 100, 'starttime' => $time, 'stoptime' => $time + (2 * 60 * 60), @@ -100,7 +98,6 @@ final class calendar_test extends \advanced_testcase { $time = time(); self::$outage = new outage([ 'id' => 1, - 'autostart' => false, 'warntime' => $time - 100, 'starttime' => $time, 'stoptime' => $time + (2 * 60 * 60), @@ -125,7 +122,6 @@ final class calendar_test extends \advanced_testcase { $time = time(); $outage = new outage([ 'id' => 1, - 'autostart' => false, 'warntime' => $time - 100, 'starttime' => $time, 'stoptime' => $time + (2 * 60 * 60), diff --git a/tests/dml/events_test.php b/tests/dml/events_test.php index 3ee83ea..0d658f1 100644 --- a/tests/dml/events_test.php +++ b/tests/dml/events_test.php @@ -62,7 +62,6 @@ final class events_test extends \advanced_testcase { // Save new outage. $now = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $now - 60, 'starttime' => 60, 'stoptime' => 120, @@ -95,7 +94,6 @@ final class events_test extends \advanced_testcase { // Save new outage. $now = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $now - 60, 'starttime' => 60, 'stoptime' => 120, @@ -133,7 +131,6 @@ final class events_test extends \advanced_testcase { // Save new outage. $now = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $now - 60, 'starttime' => 60, 'stoptime' => 120, diff --git a/tests/dml/installation_test.php b/tests/dml/installation_test.php index 0021f99..0a253ac 100644 --- a/tests/dml/installation_test.php +++ b/tests/dml/installation_test.php @@ -56,10 +56,9 @@ final class installation_test extends \auth_outage\base_testcase { static::setAdminUser(); $dbman = $DB->get_manager(); - // Create a future outage with autostart. + // Create a future outage. $now = time(); $outage = new outage([ - 'autostart' => true, 'starttime' => $now + (1 * 60 * 60), 'stoptime' => $now + (2 * 60 * 60), 'warntime' => $now - (2 * 60 * 60), diff --git a/tests/dml/outagedb_test.php b/tests/dml/outagedb_test.php index 2f102bd..13f8290 100644 --- a/tests/dml/outagedb_test.php +++ b/tests/dml/outagedb_test.php @@ -56,7 +56,6 @@ final class outagedb_test extends \auth_outage\base_testcase { /** * Helper function to create an outage then save it to the database. * - * @param bool $autostart If outage should automatically start. * @param int $now Timestamp for now, such as time(). * @param int $warning In how many hours the warning starts. Can be negative. * @param int $start In how many hours this outage starts. Can be negative. @@ -65,9 +64,8 @@ final class outagedb_test extends \auth_outage\base_testcase { * @param int|null $finished In how many hours this outage is marked as finished. Can be negative or null. * @return int Id the of created outage. */ - private static function saveoutage($autostart, $now, $warning, $start, $stop, $title, $finished = null) { + private static function saveoutage($now, $warning, $start, $stop, $title, $finished = null) { return outagedb::save(new outage([ - 'autostart' => $autostart, 'warntime' => $now + ($warning * 60 * 60), 'starttime' => $now + ($start * 60 * 60), 'stoptime' => $now + ($stop * 60 * 60), @@ -497,7 +495,6 @@ final class outagedb_test extends \auth_outage\base_testcase { $this->resetAfterTest(true); $time = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $time + (60 * 60 * 24 * 1), 'starttime' => $time + (60 * 60 * 24 * 2), 'stoptime' => $time + (60 * 60 * 24 * 3), @@ -521,15 +518,6 @@ final class outagedb_test extends \auth_outage\base_testcase { outagedb::get_next_starting(-1); } - /** - * Tests the outagedb::get_next_autostarting() with an invalid parameter. - */ - public function test_getnextautostartinginvalid(): void { - $this->resetAfterTest(true); - $this->set_expected_exception('coding_exception'); - outagedb::get_next_autostarting(-1); - } - /** * Helper function to create an outage for tests. * @param int $i Used to populate the information. @@ -537,7 +525,6 @@ final class outagedb_test extends \auth_outage\base_testcase { */ private function createoutage($i) { return new outage([ - 'autostart' => ($i % 2 == 0), 'starttime' => $i * 100, 'stoptime' => $i * 100 + 50, 'warntime' => $i * 60, diff --git a/tests/form/outage/forms_test.php b/tests/form/outage/forms_test.php index a43cde7..43bef03 100644 --- a/tests/form/outage/forms_test.php +++ b/tests/form/outage/forms_test.php @@ -67,7 +67,6 @@ final class forms_test extends \auth_outage\base_testcase { self::assertFalse($edit->is_cancelled()); $outage = $edit->get_data(); self::assertInstanceOf('\\auth_outage\\local\\outage', $outage); - self::assertSame(false, $outage->autostart); self::assertSame(60, $outage->get_warning_duration()); self::assertSame(mktime(14, 15, 0, 2, 1, 2013), $outage->starttime); self::assertSame(2 * 60 * 60, $outage->get_duration_planned()); @@ -155,7 +154,6 @@ final class forms_test extends \auth_outage\base_testcase { */ public function test_setdata(): void { $outage = new outage([ - 'autostart' => false, 'warntime' => time() - 60, 'starttime' => time(), 'stoptime' => time() + 60, diff --git a/tests/local/cli/create_test.php b/tests/local/cli/create_test.php index 8fa7133..a8e5de7 100644 --- a/tests/local/cli/create_test.php +++ b/tests/local/cli/create_test.php @@ -147,7 +147,6 @@ final class create_test extends cli_testcase { */ public function test_create_withoptions(): void { $this->set_parameters([ - '--autostart=true', '--warn=10', '--start=0', '--duration=30', @@ -177,7 +176,6 @@ final class create_test extends cli_testcase { public function test_create_onlyid(): void { $this->set_parameters([ '--onlyid', - '--autostart=N', '--warn=10', '--start=0', '--duration=30', @@ -214,7 +212,6 @@ final class create_test extends cli_testcase { $cli = new create(); $cli->set_referencetime($now); $cli->set_defaults([ - 'autostart' => false, 'warn' => 50, 'start' => 200, 'duration' => 300, @@ -243,7 +240,6 @@ final class create_test extends cli_testcase { $now = time(); // Create the outage to clone. $original = new outage([ - 'autostart' => false, 'warntime' => $now - 120, 'starttime' => $now, 'stoptime' => $now + 120, @@ -288,7 +284,6 @@ final class create_test extends cli_testcase { 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', '--block', '--warn=60', '--start=0', @@ -312,21 +307,4 @@ final class create_test extends cli_testcase { $this->set_expected_exception('coding_exception'); $cli->set_defaults(['aninvalidparameter' => 'value']); } - - /** - * Tests with an invalud autostart bool value. - */ - public function test_invalid_bool(): void { - $this->set_parameters([ - '--autostart=maybe', - '--warn=60', - '--start=0', - '--duration=600', - '--title=Title', - '--description=Description', - ]); - $cli = new create(); - $this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_INVALID); - $cli->execute(); - } } diff --git a/tests/local/cli/finish_test.php b/tests/local/cli/finish_test.php index 844f248..e44deae 100644 --- a/tests/local/cli/finish_test.php +++ b/tests/local/cli/finish_test.php @@ -93,7 +93,6 @@ final class finish_test extends cli_testcase { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now - 200, 'starttime' => $now - 100, 'stoptime' => $now - 50, @@ -114,7 +113,6 @@ final class finish_test extends cli_testcase { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now - 200, 'starttime' => $now - 100, 'stoptime' => $now + 100, diff --git a/tests/local/cli/waitforit_test.php b/tests/local/cli/waitforit_test.php index 03c9d5f..1f8b101 100644 --- a/tests/local/cli/waitforit_test.php +++ b/tests/local/cli/waitforit_test.php @@ -120,7 +120,6 @@ final class waitforit_test extends cli_testcase { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now - 200, 'starttime' => $now - 100, 'stoptime' => $now - 50, @@ -141,7 +140,6 @@ final class waitforit_test extends cli_testcase { self::setAdminUser(); $now = time(); outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now - 10, 'starttime' => $now + 1, 'stoptime' => $now + 10, @@ -164,7 +162,6 @@ final class waitforit_test extends cli_testcase { self::setAdminUser(); $now = time(); outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now, 'starttime' => $now + 45, 'stoptime' => $now + (60 * 60), @@ -193,7 +190,6 @@ final class waitforit_test extends cli_testcase { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ - 'autostart' => false, 'warntime' => $now, 'starttime' => $now + (2 * 60 * 60), 'stoptime' => $now + (60 * 60), diff --git a/tests/local/outage_test.php b/tests/local/outage_test.php index c550b0e..83ece5c 100644 --- a/tests/local/outage_test.php +++ b/tests/local/outage_test.php @@ -48,7 +48,6 @@ final class outage_test extends \auth_outage\base_testcase { public function test_constructor_object(): void { $obj = new \stdClass(); $obj->id = 1; - $obj->autostart = true; $obj->warntime = 2; $obj->starttime = 3; $obj->finished = 4; @@ -57,7 +56,6 @@ final class outage_test extends \auth_outage\base_testcase { $obj->description = 'Description'; $outage = new outage($obj); self::assertSame($obj->id, $outage->id); - self::assertSame($obj->autostart, $outage->autostart); self::assertSame($obj->warntime, $outage->warntime); self::assertSame($obj->starttime, $outage->starttime); self::assertSame($obj->finished, $outage->finished); diff --git a/tests/local/outagelib_test.php b/tests/local/outagelib_test.php index 12595ef..0c6518e 100644 --- a/tests/local/outagelib_test.php +++ b/tests/local/outagelib_test.php @@ -42,7 +42,6 @@ final class outagelib_test extends \auth_outage\base_testcase { $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -82,7 +81,6 @@ final class outagelib_test extends \auth_outage\base_testcase { self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -128,7 +126,6 @@ final class outagelib_test extends \auth_outage\base_testcase { self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -171,7 +168,6 @@ final class outagelib_test extends \auth_outage\base_testcase { self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -205,7 +201,6 @@ final class outagelib_test extends \auth_outage\base_testcase { $this->resetAfterTest(true); $keys = [ 'css', - 'default_autostart', 'default_description', 'default_duration', 'default_title', @@ -236,7 +231,6 @@ final class outagelib_test extends \auth_outage\base_testcase { $keys = [ 'allowedips', 'css', - 'default_autostart', 'default_description', 'default_duration', 'default_title', @@ -257,7 +251,6 @@ final class outagelib_test extends \auth_outage\base_testcase { // Set config with invalid values. set_config('allowedips', " \n", 'auth_outage'); set_config('css', " \n", 'auth_outage'); - set_config('default_autostart', " \n", 'auth_outage'); set_config('default_description', " \n", 'auth_outage'); set_config('default_duration', " \n", 'auth_outage'); set_config('default_title', " \n", 'auth_outage'); @@ -281,7 +274,6 @@ final class outagelib_test extends \auth_outage\base_testcase { self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -531,21 +523,6 @@ EOT; } } - /** - * Related to Issue #70: Creating ongoing outage does not trigger maintenance file creation. - */ - public function test_preparenextoutage_notautostart(): void { - global $CFG; - - $this->create_outage(); - - // The method outagelib::prepare_next_outage() should have been called by save(). - foreach ([$CFG->dataroot . '/climaintenance.template.html', $CFG->dataroot . '/climaintenance.php'] as $file) { - self::assertFileExists($file); - unlink($file); - } - } - /** * Regression Test - Issue #82: When changing the IP address list it should recreate the maintenance files. */ @@ -582,36 +559,6 @@ EOT; } } - /** - * Related to Issue #72: IP Block still triggers cli maintenance mode even without autostart. - */ - public function test_preparenextoutage_noautostarttrigger(): void { - global $CFG; - - $this->resetAfterTest(true); - self::setAdminUser(); - $now = time(); - $outage = new outage([ - 'autostart' => false, - 'warntime' => $now - 200, - 'starttime' => $now - 100, - 'stoptime' => $now + 200, - 'title' => 'Title', - 'description' => 'Description', - ]); - outagedb::save($outage); - - // The method outagelib::prepare_next_outage() should have been called by save(). - self::assertFalse(get_config('moodle', 'maintenance_later')); - // This file should not exist even if the statement above fails as Moodle does not create it immediately but test anyway. - // Backwards compatibility with older PHPUnit - use old assertFile method. - if (method_exists($this, 'assertFileDoesNotExist')) { - self::assertFileDoesNotExist($CFG->dataroot . '/climaintenance.html'); - } else { - self::assertFileNotExists($CFG->dataroot . '/climaintenance.html'); - } - } - /** * Regression test for issue #85. */ @@ -622,7 +569,6 @@ EOT; self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => true, 'warntime' => $now, 'starttime' => $now + 100, 'stoptime' => $now + 200, @@ -652,7 +598,6 @@ EOT; self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $now - 200, 'starttime' => $now - 100, 'stoptime' => $now + 200, @@ -768,7 +713,6 @@ EOT; self::setAdminUser(); $now = time(); $outage = new outage([ - 'autostart' => false, 'warntime' => $now - 200, 'starttime' => $now - 100, 'stoptime' => $now + 200,