Skip to content

Commit

Permalink
test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 16, 2019
1 parent 6b8fe96 commit 1a4ebd7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');

});

Expand Down
9 changes: 6 additions & 3 deletions src/HeroFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 1a4ebd7

Please sign in to comment.