From 5bf0496c79f60bf68e4504105a7a89ba342d45d5 Mon Sep 17 00:00:00 2001 From: Noemie Ariste Date: Fri, 25 Feb 2022 20:17:58 +1300 Subject: [PATCH] Update assertFileNotExists() to assertFileDoesNotExist() --- .../maintenance_static_page_test.php | 7 ++++++- tests/phpunit/local/outagelib_test.php | 21 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/local/controllers/maintenance_static_page_test.php b/tests/phpunit/local/controllers/maintenance_static_page_test.php index a9108f6..0bfa6f5 100644 --- a/tests/phpunit/local/controllers/maintenance_static_page_test.php +++ b/tests/phpunit/local/controllers/maintenance_static_page_test.php @@ -297,7 +297,12 @@ class auth_outage_maintenance_static_page_test extends auth_outage_base_testcase touch($file); self::assertFileExists($file); maintenance_static_page::create_from_outage(null)->generate(); - self::assertFileNotExists($file); + // Backwards compatibility with older PHPUnit - use old assertFile method. + if (method_exists($this, 'assertFileDoesNotExist')) { + self::assertFileDoesNotExist($file); + } else { + self::assertFileNotExists($file); + } } /** diff --git a/tests/phpunit/local/outagelib_test.php b/tests/phpunit/local/outagelib_test.php index cf98215..2a7b687 100644 --- a/tests/phpunit/local/outagelib_test.php +++ b/tests/phpunit/local/outagelib_test.php @@ -404,7 +404,12 @@ EOT; touch($file); outagelib::update_climaintenance_code($outage); - self::assertFileNotExists($file); + // Backwards compatibility with older PHPUnit - use old assertFile method. + if (method_exists($this, 'assertFileDoesNotExist')) { + self::assertFileDoesNotExist($file); + } else { + self::assertFileNotExists($file); + } } /** @@ -416,7 +421,12 @@ EOT; touch($file); outagelib::update_climaintenance_code(null); - self::assertFileNotExists($file); + // Backwards compatibility with older PHPUnit - use old assertFile method. + if (method_exists($this, 'assertFileDoesNotExist')) { + self::assertFileDoesNotExist($file); + } else { + self::assertFileNotExists($file); + } } /** @@ -492,7 +502,12 @@ EOT; // 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. - self::assertFileNotExists($CFG->dataroot.'/climaintenance.html'); + // 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'); + } } /**