Skip to content

Commit 4a1ff08

Browse files
committed
Fix PHPUnit 9.6 deprecations
1 parent 023e103 commit 4a1ff08

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Tests/ExpressionLanguageTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,25 @@ public function testNullSafeEvaluateFails($expression, $foo, $message)
311311
/**
312312
* @dataProvider provideInvalidNullSafe
313313
*/
314-
public function testNullSafeCompileFails($expression, $foo)
314+
public function testNullSafeCompileFails($expression)
315315
{
316316
$expressionLanguage = new ExpressionLanguage();
317317

318-
$this->expectWarning();
319-
eval(sprintf('return %s;', $expressionLanguage->compile($expression, ['foo' => 'foo'])));
318+
$this->expectException(\ErrorException::class);
319+
320+
set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool {
321+
if ($errno & (\E_WARNING | \E_USER_WARNING)) {
322+
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
323+
}
324+
325+
return false;
326+
});
327+
328+
try {
329+
eval(sprintf('return %s;', $expressionLanguage->compile($expression, ['foo' => 'foo'])));
330+
} finally {
331+
restore_error_handler();
332+
}
320333
}
321334

322335
public static function provideInvalidNullSafe()

0 commit comments

Comments
 (0)