Skip to content

Commit 1a4ebd7

Browse files
committed
test clean up
1 parent 6b8fe96 commit 1a4ebd7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262

6363
it('empty as rely to original mvc process to handle', function() {
6464

65+
@mkdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview', 0755, true);
66+
file_put_contents(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml', '');
67+
6568
$request = $this->application->getRequest();
6669
$request->setMethod('GET');
6770
$request->setUri('http://example.com/error-preview/notice');
@@ -72,9 +75,12 @@
7275
$content = \ob_get_clean();
7376

7477
expect(\ob_get_clean())->toBe('');
75-
$this->application->getResponse()->setStatusCode(http_response_code());
76-
expect($this->application->getResponse()->getStatusCode())->toBe(500);
78+
// yes, excluded E_* error means it ignored, means it passed, means it is 200 status code
79+
expect($this->application->getResponse()->getStatusCode())->toBe(200);
7780

81+
unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml');
82+
rmdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview');
83+
rmdir(__DIR__ . '/../Fixture/view/error-hero-module');
7884

7985
});
8086

src/HeroFunction.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ function isExcludedException(array $excludeExceptionsConfig, Throwable $t)
1818
{
1919
$exceptionOrErrorClass = \get_class($t);
2020

21+
$isExcluded = false;
2122
foreach ($excludeExceptionsConfig as $excludeException) {
2223
if ($exceptionOrErrorClass === $excludeException) {
23-
return true;
24+
$isExcluded = true;
25+
break;
2426
}
2527

2628
if (is_array($excludeException)
2729
&& $excludeException[0] === $exceptionOrErrorClass
2830
&& $excludeException[1] === $t->getMessage()
2931
) {
30-
return true;
32+
$isExcluded = true;
33+
break;
3134
}
3235
}
3336

34-
return false;
37+
return $isExcluded;
3538
}

0 commit comments

Comments
 (0)