diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 7cb8d486..db99639c 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -27,9 +27,14 @@ class Handler /** * Activate the error handler + * @codeCoverageIgnore */ public function register(): void { + if (defined('PHPUNIT_COMPOSER_INSTALL')) { + return; + } + set_error_handler([$this, 'errorHandler']); set_exception_handler([$this, 'exceptionHandler']); } diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php index 456c7ad1..05a0ac84 100644 --- a/tests/Unit/Exceptions/HandlerTest.php +++ b/tests/Unit/Exceptions/HandlerTest.php @@ -80,25 +80,6 @@ class HandlerTest extends TestCase $this->assertEquals($errorMessage, $return); } - /** - * @covers \Engelsystem\Exceptions\Handler::register() - */ - public function testRegister(): void - { - /** @var Handler|MockObject $handler */ - $handler = $this->getMockForAbstractClass(Handler::class); - $handler->register(); - - set_error_handler($errorHandler = set_error_handler('var_dump')); - $this->assertEquals($handler, array_shift($errorHandler)); - - set_exception_handler($exceptionHandler = set_error_handler('var_dump')); - $this->assertEquals($handler, array_shift($exceptionHandler)); - - restore_error_handler(); - restore_exception_handler(); - } - /** * @covers \Engelsystem\Exceptions\Handler::getEnvironment() * @covers \Engelsystem\Exceptions\Handler::setEnvironment()