From bc556578b303c0a188cc99c79e8a0234b616b314 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 18 Sep 2020 10:56:27 +0000 Subject: [PATCH] Tests: Fix the failure in `test_get_weekday_undefined_index()` on PHP 8. The test ensures that `WP_Locale::get_weekday()` throws an "undefined offset" notice when called with an incorrect `$weekday_number` parameter. In PHP 8, that notice is now a warning, so the test needs to be adjusted accordingly. See #50913. git-svn-id: https://develop.svn.wordpress.org/trunk@48993 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/locale.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/locale.php b/tests/phpunit/tests/locale.php index a51df0a5b4..449471c5d5 100644 --- a/tests/phpunit/tests/locale.php +++ b/tests/phpunit/tests/locale.php @@ -25,10 +25,13 @@ class Tests_Locale extends WP_UnitTestCase { $this->assertSame( __( 'Saturday' ), $this->locale->get_weekday( 6 ) ); } - /** - * @expectedException PHPUnit_Framework_Error_Notice - */ public function test_get_weekday_undefined_index() { + if ( PHP_VERSION_ID >= 80000 ) { + $this->expectException( 'PHPUnit_Framework_Error_Warning' ); + } else { + $this->expectException( 'PHPUnit_Framework_Error_Notice' ); + } + $this->locale->get_weekday( 7 ); }