From 5cc215d8197ba561caf6759389d80d780250fe67 Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Thu, 27 Feb 2025 15:32:25 +1300 Subject: [PATCH 1/4] add tearDown method to base runtest --- tests/base_testcase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/base_testcase.php b/tests/base_testcase.php index 1976ad2..d5cc3af 100644 --- a/tests/base_testcase.php +++ b/tests/base_testcase.php @@ -105,5 +105,6 @@ abstract class base_testcase extends \core_phpunit\testcase { foreach (outagedb::get_all() as $i => $outage) { $DB->delete_records('auth_outage', ['id' => $outage->id]); } + parent::tearDown(); } } From 25b9e553a5cda97bfb5e0b5a7fce4f2009a8ceca Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Thu, 27 Feb 2025 15:33:10 +1300 Subject: [PATCH 2/4] update test fixture path --- tests/fixtures/withurls-quoted.css | 2 +- tests/fixtures/withurls.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/withurls-quoted.css b/tests/fixtures/withurls-quoted.css index abfd76d..d5c287c 100644 --- a/tests/fixtures/withurls-quoted.css +++ b/tests/fixtures/withurls-quoted.css @@ -3,5 +3,5 @@ a { } div { - background-image: url('/moodle/auth/outage/tests/local/controllers/fixtures/catalyst.png'); + background-image: url('/moodle/auth/outage/tests/fixtures/catalyst.png'); } diff --git a/tests/fixtures/withurls.css b/tests/fixtures/withurls.css index 9b6ef0f..3b08b90 100644 --- a/tests/fixtures/withurls.css +++ b/tests/fixtures/withurls.css @@ -3,5 +3,5 @@ a { } div { - background-image: url(/moodle/auth/outage/tests/local/controllers/fixtures/catalyst.png); + background-image: url(/moodle/auth/outage/tests/fixtures/catalyst.png); } From ca4a20275293eb5b078cd0f161c417ff52b0ff02 Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Tue, 4 Mar 2025 08:17:04 +1300 Subject: [PATCH 3/4] Remove redundant use statements with non-compound name --- tests/controllers_infopage_test.php | 1 - tests/controllers_maintenance_static_page_test.php | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/controllers_infopage_test.php b/tests/controllers_infopage_test.php index d78e6ce..5ca176c 100644 --- a/tests/controllers_infopage_test.php +++ b/tests/controllers_infopage_test.php @@ -25,7 +25,6 @@ use auth_outage\local\outage; use auth_outage\local\controllers\infopage; -use context_system; defined('MOODLE_INTERNAL') || die(); require_once(__DIR__.'/base_testcase.php'); diff --git a/tests/controllers_maintenance_static_page_test.php b/tests/controllers_maintenance_static_page_test.php index 3c142f8..def7166 100644 --- a/tests/controllers_maintenance_static_page_test.php +++ b/tests/controllers_maintenance_static_page_test.php @@ -27,7 +27,6 @@ use auth_outage\task\update_static_page; use auth_outage\local\controllers\maintenance_static_page; use auth_outage\local\controllers\maintenance_static_page_io; use auth_outage\local\controllers\maintenance_static_page_generator; -use DOMDocument; defined('MOODLE_INTERNAL') || die(); require_once(__DIR__.'/base_testcase.php'); From 478d0fc5c12504594148b06e948a8af4dee8fd52 Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Tue, 4 Mar 2025 08:18:47 +1300 Subject: [PATCH 4/4] Run class in separate process ensuring tearDown method gets called --- tests/outagelib_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/outagelib_test.php b/tests/outagelib_test.php index e41efa0..827a736 100644 --- a/tests/outagelib_test.php +++ b/tests/outagelib_test.php @@ -747,7 +747,7 @@ EOT; * * We need this because we modify the request headers, * see https://github.com/sebastianbergmann/phpunit/issues/720#issuecomment-10421092 - * @runInSeparateProcess + * @runClassInSeparateProcess */ public function test_evaluation_maintenancepage(?string $allowedips, ?string $iptouse, ?string $accesskey, ?string $accesskeytouse, array $expectedoutputs) {