From 1a4ebd77e896079457bc6ee4771a9eb21b46559d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 16 Dec 2019 10:16:20 +0700 Subject: [PATCH] test clean up --- ...eviewControllerForSpecificErrorAndExceptionSpec.php | 10 ++++++++-- src/HeroFunction.php | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php b/spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php index f3666fcd..7f945368 100644 --- a/spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php +++ b/spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php @@ -62,6 +62,9 @@ it('empty as rely to original mvc process to handle', function() { + @mkdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview', 0755, true); + file_put_contents(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml', ''); + $request = $this->application->getRequest(); $request->setMethod('GET'); $request->setUri('http://example.com/error-preview/notice'); @@ -72,9 +75,12 @@ $content = \ob_get_clean(); expect(\ob_get_clean())->toBe(''); - $this->application->getResponse()->setStatusCode(http_response_code()); - expect($this->application->getResponse()->getStatusCode())->toBe(500); + // yes, excluded E_* error means it ignored, means it passed, means it is 200 status code + expect($this->application->getResponse()->getStatusCode())->toBe(200); + unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml'); + rmdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview'); + rmdir(__DIR__ . '/../Fixture/view/error-hero-module'); }); diff --git a/src/HeroFunction.php b/src/HeroFunction.php index 3bf0f10f..67ef09a7 100644 --- a/src/HeroFunction.php +++ b/src/HeroFunction.php @@ -18,18 +18,21 @@ function isExcludedException(array $excludeExceptionsConfig, Throwable $t) { $exceptionOrErrorClass = \get_class($t); + $isExcluded = false; foreach ($excludeExceptionsConfig as $excludeException) { if ($exceptionOrErrorClass === $excludeException) { - return true; + $isExcluded = true; + break; } if (is_array($excludeException) && $excludeException[0] === $exceptionOrErrorClass && $excludeException[1] === $t->getMessage() ) { - return true; + $isExcluded = true; + break; } } - return false; + return $isExcluded; }