diff --git a/backup/util/settings/tests/settings_test.php b/backup/util/settings/tests/settings_test.php index 289f30fec7f..1f512d563a9 100644 --- a/backup/util/settings/tests/settings_test.php +++ b/backup/util/settings/tests/settings_test.php @@ -128,7 +128,7 @@ class backp_settings_testcase extends basic_testcase { $this->assertEquals($e->errorcode, 'incorrect_object_passed'); } catch (TypeError $e) { // On PHP7+ we get a TypeError raised, lets check we've the right error. - $this->assertMatchesRegularExpression('/must be an instance of backup_setting_ui/', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be (of type|an instance of) backup_setting_ui/', $e->getMessage()); } restore_error_handler(); @@ -145,7 +145,7 @@ class backp_settings_testcase extends basic_testcase { $this->assertEquals($e->errorcode, 'incorrect_object_passed'); } catch (TypeError $e) { // On PHP7+ we get a TypeError raised, lets check we've the right error. - $this->assertMatchesRegularExpression('/must be an instance of backup_setting_ui/', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be (of type|an instance of) backup_setting_ui/', $e->getMessage()); } restore_error_handler(); @@ -354,7 +354,7 @@ class backp_settings_testcase extends basic_testcase { $this->assertEquals($e->errorcode, 'incorrect_object_passed'); } catch (TypeError $e) { // On PHP7+ we get a TypeError raised, lets check we've the right error. - $this->assertMatchesRegularExpression('/must be an instance of base_setting/', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be (an instance of|of type) base_setting/', $e->getMessage()); } restore_error_handler(); diff --git a/lib/phpunit/tests/basic_test.php b/lib/phpunit/tests/basic_test.php index df989ee6a77..53f25936142 100644 --- a/lib/phpunit/tests/basic_test.php +++ b/lib/phpunit/tests/basic_test.php @@ -96,7 +96,6 @@ class core_phpunit_basic_testcase extends basic_testcase { $this->assertEquals(1, '1'); $this->assertEquals(null, ''); - $this->assertNotEquals(1, '1 '); $this->assertNotEquals(0, ''); $this->assertNotEquals(null, '0'); $this->assertNotEquals(array(), ''); diff --git a/lib/tests/encryption_test.php b/lib/tests/encryption_test.php index 60094f02a8b..81602d1472e 100644 --- a/lib/tests/encryption_test.php +++ b/lib/tests/encryption_test.php @@ -216,7 +216,7 @@ class encryption_testcase extends \basic_testcase { switch ($method) { case encryption::METHOD_SODIUM: - $this->expectExceptionMessage('key size should be'); + $this->expectExceptionMessageMatches('/(should|must) be SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes/'); break; case encryption::METHOD_OPENSSL: diff --git a/lib/tests/event_test.php b/lib/tests/event_test.php index 476eaf66efb..208482482c9 100644 --- a/lib/tests/event_test.php +++ b/lib/tests/event_test.php @@ -857,7 +857,11 @@ class core_event_testcase extends advanced_testcase { // all that was done is to move the annotation (deprecated) to // explicit expectation. Still try commenting it out and you'll see // the notice. - $this->expectNotice(); + if (PHP_VERSION_ID >= 80000) { + $this->expectWarning(); + } else { + $this->expectNotice(); + } $event = \core_tests\event\context_used_in_event::create(array('other' => array('sample' => 1, 'xx' => 10))); $this->assertEventContextNotUsed($event); diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index bc8315c78ff..34f2f1c0a7d 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -2302,7 +2302,11 @@ EOF; public function test_get_string_limitation() { // This is one of the limitations to the lang_string class. It can't be // used as a key. - $this->expectWarning(); + if (PHP_VERSION_ID >= 80000) { + $this->expectException(TypeError::class); + } else { + $this->expectWarning(); + } $array = array(get_string('yes', null, null, true) => 'yes'); } diff --git a/mod/forum/tests/mail_test.php b/mod/forum/tests/mail_test.php index 8f6725801c6..c9d0247b8b8 100644 --- a/mod/forum/tests/mail_test.php +++ b/mod/forum/tests/mail_test.php @@ -1016,8 +1016,8 @@ class mod_forum_mail_testcase extends advanced_testcase { 'contents' => array( '~{$a', '~&(amp|lt|gt|quot|\#039);(?!course)', - 'Attachment example.txt:' . PHP_EOL . - 'https://www.example.com/moodle/pluginfile.php/\d*/mod_forum/attachment/\d*/example.txt' . PHP_EOL, + 'Attachment example.txt:' . '\r*\n' . + 'https://www.example.com/moodle/pluginfile.php/\d*/mod_forum/attachment/\d*/example.txt' . '\r*\n', 'Hello Moodle', 'Moodle Forum', 'Welcome.*Moodle', 'Love Moodle', '1\d1' ), ), @@ -1075,12 +1075,12 @@ class mod_forum_mail_testcase extends advanced_testcase { $newcase['expectations'][0]['contents'] = array( '~{$a', '~&(amp|lt|gt|quot|\#039);(?!course)', - 'Attachment example.txt:' . PHP_EOL . - 'https://www.example.com/moodle/pluginfile.php/\d*/mod_forum/attachment/\d*/example.txt' . PHP_EOL , + 'Attachment example.txt:' . '\r*\n' . + 'https://www.example.com/moodle/pluginfile.php/\d*/mod_forum/attachment/\d*/example.txt' . '\r*\n' , 'Text and image', 'Moodle Forum', - 'Welcome to Moodle, *' . PHP_EOL . '.*' + 'Welcome to Moodle, *' . '\r*\n' . '.*' .'https://www.example.com/moodle/pluginfile.php/\d+/mod_forum/post/\d+/' - .'Screen%20Shot%202016-03-22%20at%205\.54\.36%20AM%20%281%29\.png *' . PHP_EOL . '.*!', + .'Screen%20Shot%202016-03-22%20at%205\.54\.36%20AM%20%281%29\.png *' . '\r*\n' . '.*!', 'Love Moodle', '1\d1'); $textcases['Text mail with text+image message i.e. @@PLUGINFILE@@ token handling'] = array('data' => $newcase);