Browse Source

Add tests for trace logging change.

When trace + log are true, exceptions should be logged, when trace is
false, no exception traces should be logged.

Refs #6589
Mark Story 10 years ago
parent
commit
4a6c7e81fa
1 changed files with 15 additions and 1 deletions
  1. 15 1
      tests/TestCase/Error/ErrorHandlerTest.php

+ 15 - 1
tests/TestCase/Error/ErrorHandlerTest.php

@@ -251,19 +251,33 @@ class ErrorHandlerTest extends TestCase
     {
         $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);
     }
 
     /**