|
|
@@ -195,8 +195,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testHandleException() {
|
|
|
- $this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.');
|
|
|
-
|
|
|
$error = new NotFoundException('Kaboom!');
|
|
|
ob_start();
|
|
|
ErrorHandler::handleException($error);
|
|
|
@@ -210,8 +208,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testHandleExceptionLog() {
|
|
|
- $this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.');
|
|
|
-
|
|
|
if (file_exists(LOGS . 'error.log')) {
|
|
|
unlink(LOGS . 'error.log');
|
|
|
}
|
|
|
@@ -224,8 +220,37 @@ class ErrorHandlerTest extends CakeTestCase {
|
|
|
$this->assertRegExp('/Kaboom!/', $result, 'message missing.');
|
|
|
|
|
|
$log = file(LOGS . 'error.log');
|
|
|
- $this->assertRegExp('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.');
|
|
|
- $this->assertRegExp('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[2], 'Stack trace missing.');
|
|
|
+ $this->assertContains('[NotFoundException] Kaboom!', $log[0], 'message missing.');
|
|
|
+ $this->assertContains('ErrorHandlerTest->testHandleExceptionLog', $log[2], 'Stack trace missing.');
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test handleException generating log.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testHandleExceptionLogSkipping() {
|
|
|
+ if (file_exists(LOGS . 'error.log')) {
|
|
|
+ unlink(LOGS . 'error.log');
|
|
|
+ }
|
|
|
+ Configure::write('Exception.log', true);
|
|
|
+ Configure::write('Exception.skipLog', array('NotFoundException'));
|
|
|
+ $notFound = new NotFoundException('Kaboom!');
|
|
|
+ $forbidden = new ForbiddenException('Fooled you!');
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ ErrorHandler::handleException($notFound);
|
|
|
+ $result = ob_get_clean();
|
|
|
+ $this->assertRegExp('/Kaboom!/', $result, 'message missing.');
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ ErrorHandler::handleException($forbidden);
|
|
|
+ $result = ob_get_clean();
|
|
|
+ $this->assertRegExp('/Fooled you!/', $result, 'message missing.');
|
|
|
+
|
|
|
+ $log = file(LOGS . 'error.log');
|
|
|
+ $this->assertNotContains('[NotFoundException] Kaboom!', $log[0], 'message should not be logged.');
|
|
|
+ $this->assertContains('[ForbiddenException] Fooled you!', $log[0], 'message missing.');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -257,8 +282,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testHandleFatalErrorPage() {
|
|
|
- $this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.');
|
|
|
-
|
|
|
$line = __LINE__;
|
|
|
|
|
|
ob_start();
|
|
|
@@ -286,8 +309,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testHandleFatalErrorLog() {
|
|
|
- $this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.');
|
|
|
-
|
|
|
if (file_exists(LOGS . 'error.log')) {
|
|
|
unlink(LOGS . 'error.log');
|
|
|
}
|