tests: Removed exception handler registration because it has side effects

This commit is contained in:
Igor Scheller 2023-01-21 01:37:09 +01:00
parent 733586dfd5
commit f5a7598a45
2 changed files with 5 additions and 19 deletions

View File

@ -27,9 +27,14 @@ class Handler
/** /**
* Activate the error handler * Activate the error handler
* @codeCoverageIgnore
*/ */
public function register(): void public function register(): void
{ {
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
return;
}
set_error_handler([$this, 'errorHandler']); set_error_handler([$this, 'errorHandler']);
set_exception_handler([$this, 'exceptionHandler']); set_exception_handler([$this, 'exceptionHandler']);
} }

View File

@ -80,25 +80,6 @@ class HandlerTest extends TestCase
$this->assertEquals($errorMessage, $return); $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::getEnvironment()
* @covers \Engelsystem\Exceptions\Handler::setEnvironment() * @covers \Engelsystem\Exceptions\Handler::setEnvironment()