summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold Daniels <arnold@jasny.net>2017-01-25 02:27:18 +0100
committerArnold Daniels <arnold@jasny.net>2017-01-25 02:27:18 +0100
commit38e076fc36d86689010081bc2eab96f12d97b0d8 (patch)
tree4201e788beb66a8bcd8f4f93bc924ce19dc26c2d
parentb7f9fab71b4c876ba0e3cd0fa4e4f5f9c03d2fcb (diff)
downloaderror-handler-origin/HEAD.zip
error-handler-origin/HEAD.tar.gz
error-handler-origin/HEAD.tar.bz2
-rw-r--r--tests/ErrorHandlerTest.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/ErrorHandlerTest.php b/tests/ErrorHandlerTest.php
index 46776fc..8dbac69 100644
--- a/tests/ErrorHandlerTest.php
+++ b/tests/ErrorHandlerTest.php
@@ -5,9 +5,9 @@ namespace Jasny;
use Jasny\ErrorHandler;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use PHPUnit_Framework_MockObject_Matcher_InvokedCount as InvokedCount;
+use Jasny\TestHelper;
/**
* @covers Jasny\ErrorHandler
@@ -20,6 +20,8 @@ use PHPUnit_Framework_MockObject_Matcher_InvokedCount as InvokedCount;
*/
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
+ use TestHelper;
+
/**
* @var ErrorHandler|MockObject
*/
@@ -393,6 +395,22 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
}
}
+ public function testHandleErrorChaining()
+ {
+ $handler = $this->createCallbackMock($this->once(), [E_USER_WARNING, 'no good', 'foo.php', 42, []], false);
+
+ $errorHandler = $this->errorHandler;
+ $errorHandler->expects($this->once())->method('errorReporting')->willReturn(E_ALL | E_STRICT);
+ $errorHandler->expects($this->once())->method('setErrorHandler')->willReturn($handler);
+
+ $errorHandler->logUncaught(E_USER_WARNING);
+
+ $ret = $errorHandler->handleError(E_USER_WARNING, 'no good', 'foo.php', 42, []);
+
+ $this->assertSame($ret, false);
+ }
+
+
public function handleExceptionProvider()
{
return [
@@ -443,13 +461,9 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testHandleExceptionChaining()
{
$exception = new \Exception('no good');
-
- $handler = $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock();
- $handler->expects($this->once())->method('__invoke')
- ->with($exception);
+ $handler = $this->createCallbackMock($this->once(), [$exception]);
$errorHandler = $this->errorHandler;
-
$errorHandler->expects($this->exactly(2))->method('setExceptionHandler')
->withConsecutive([[$errorHandler, 'handleException']], [null])
->willReturnOnConsecutiveCalls($handler, [$errorHandler, 'handleException']);