Skip to content

Commit

Permalink
Add tests for trace logging change.
Browse files Browse the repository at this point in the history
When trace + log are true, exceptions should be logged, when trace is
false, no exception traces should be logged.

Refs #6589
  • Loading branch information
markstory committed May 19, 2015
1 parent 68ace0b commit 4a6c7e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -251,19 +251,33 @@ public function testHandleExceptionLog()
{
$errorHandler = new TestErrorHandler([
'log' => true,
'trace' => true,
]);

$error = new NotFoundException('Kaboom!');

$this->_logger->expects($this->once())
$this->_logger->expects($this->at(0))
->method('log')
->with('error', $this->logicalAnd(
$this->stringContains('[Cake\Network\Exception\NotFoundException] Kaboom!'),
$this->stringContains('ErrorHandlerTest->testHandleExceptionLog')
));

$this->_logger->expects($this->at(1))
->method('log')
->with('error', $this->logicalAnd(
$this->stringContains('[Cake\Network\Exception\NotFoundException] Kaboom!'),
$this->logicalNot($this->stringContains('ErrorHandlerTest->testHandleExceptionLog'))
));

$errorHandler->handleException($error);
$this->assertContains('Kaboom!', $errorHandler->response->body(), 'message missing.');

$errorHandler = new TestErrorHandler([
'log' => true,
'trace' => false,
]);
$errorHandler->handleException($error);
}

/**
Expand Down

0 comments on commit 4a6c7e8

Please sign in to comment.