mirror of
https://github.com/filp/whoops.git
synced 2026-10-12 15:06:24 +00:00
Allow catching PHP errors
This commit is contained in:
+1
-5
@@ -353,11 +353,7 @@ class Run
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->handleException(
|
||||
new ErrorException(
|
||||
$message, $level, 0, $file, $line
|
||||
)
|
||||
);
|
||||
throw new ErrorException($message, $level, 0, $file, $line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,33 @@ class RunTest extends TestCase
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testErrorCatching()
|
||||
{
|
||||
$run = $this->getRunInstance();
|
||||
$run->register();
|
||||
|
||||
$handler = $this->getHandler();
|
||||
$run->pushHandler($handler);
|
||||
|
||||
$test = $this;
|
||||
$handler
|
||||
->shouldReceive('handle')
|
||||
->andReturnUsing(function () use($test) {
|
||||
$test->fail('$handler should not be called error should be caught');
|
||||
})
|
||||
;
|
||||
|
||||
try {
|
||||
trigger_error(E_USER_NOTICE, 'foo');
|
||||
$this->fail('Should not continue after error thrown');
|
||||
} catch (\ErrorException $e) {
|
||||
// Do nothing
|
||||
$this->assertTrue(true);
|
||||
return;
|
||||
}
|
||||
$this->fail('Should not continue here, should have been caught.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to make sure that error_reporting is respected.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user