diff --git a/tests/TestCase/Error/ErrorHandlerTest.php b/tests/TestCase/Error/ErrorHandlerTest.php index cad67dba078..244ad2c70e9 100644 --- a/tests/TestCase/Error/ErrorHandlerTest.php +++ b/tests/TestCase/Error/ErrorHandlerTest.php @@ -21,6 +21,7 @@ use Cake\Error; use Cake\Error\ErrorHandler; use Cake\Error\ExceptionRenderer; +use Cake\Error\PHP7ErrorException; use Cake\Log\Log; use Cake\Network\Exception\ForbiddenException; use Cake\Network\Exception\NotFoundException; @@ -29,6 +30,7 @@ use Cake\Routing\Exception\MissingControllerException; use Cake\Routing\Router; use Cake\TestSuite\TestCase; +use ParseError; /** * Testing stub. @@ -416,4 +418,19 @@ public function testHandleFatalErrorLog() $errorHandler = new TestErrorHandler(['log' => true]); $errorHandler->handleFatalError(E_ERROR, 'Something wrong', __FILE__, __LINE__); } + + /** + * Tests Handling a PHP7 error + * + * @return void + */ + public function testHandlePHP7Error() + { + $this->skipIf(!class_exists('Error'), 'Requires PHP7'); + $error = new PHP7ErrorException(new ParseError('Unexpected variable foo')); + $errorHandler = new TestErrorHandler(); + + $errorHandler->handleException($error); + $this->assertContains('Unexpected variable foo', $errorHandler->response->body(), 'message missing.'); + } }