Skip to content

Commit

Permalink
Added test for handling of PHP 7 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 15, 2015
1 parent 8410fd4 commit fc5ce30
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -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;
Expand All @@ -29,6 +30,7 @@
use Cake\Routing\Exception\MissingControllerException;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use ParseError;

/**
* Testing stub.
Expand Down Expand Up @@ -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.');
}
}

0 comments on commit fc5ce30

Please sign in to comment.