From 128f78c1cff3c5f1d4b041bc4458d174fbec07c8 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 2 Nov 2022 11:40:34 +1300 Subject: [PATCH] FIX Filter out E_USER_DEPRECATED unrelated to unit test --- tests/php/Dev/DeprecationTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index 0103e710f..ed6018714 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -24,12 +24,18 @@ class DeprecationTest extends SapphireTest // https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210 parent::setup(); $this->oldHandler = set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { - if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) { - throw new Deprecated($errstr, $errno, '', 1); + if ($errno === E_USER_DEPRECATED) { + if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) { + throw new Deprecated($errstr, $errno, '', 1); + } else { + // Surpress any E_USER_DEPRECATED unrelated to this unit-test + return true; + } } if (is_callable($this->oldHandler)) { return call_user_func($this->oldHandler, $errno, $errstr, $errfile, $errline); } + // Fallback to default PHP error handler return false; }); }