Skip to content

Commit

Permalink
Merge pull request #179 from Yoast/feature/1.x-php-8.4-restrict-test
Browse files Browse the repository at this point in the history
PHP 8.4 | Silence deprecation notice in the tests
  • Loading branch information
jrfnl authored Aug 30, 2024
2 parents 05495b9 + 7ecb112 commit f3a7fbd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/Polyfills/ExpectPHPExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,23 @@ public function testWarningCanBeExpected() {
/**
* Verify availability of the expectError*() methods.
*
* @requires PHP < 9.0
*
* @return void
*/
public function testErrorCanBeExpected() {
$this->expectError();
$this->expectErrorMessage( 'foo' );
$this->expectErrorMessageMatches( '/foo/' );

\trigger_error( 'foo', \E_USER_ERROR );
if ( \PHP_VERSION_ID < 80400 ) {
\trigger_error( 'foo', \E_USER_ERROR );
}
else {
// PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`.
// Silence the deprecation notice (but not the error itself).
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
@\trigger_error( 'foo', \E_USER_ERROR );
}
}
}

0 comments on commit f3a7fbd

Please sign in to comment.