From 6eea072376cc9fd1034342a0e1d2173681268138 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 20 Nov 2017 17:08:05 +0100 Subject: Added ExceptionHandler Interface --- .../Exceptions/ExceptionsServiceProviderTest.php | 6 ++-- tests/Unit/Exceptions/HandlerTest.php | 38 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/Exceptions/HandlerTest.php (limited to 'tests') diff --git a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php index 9c943d52..01fb2f11 100644 --- a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php +++ b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php @@ -2,8 +2,9 @@ namespace Engelsystem\Test\Unit\Exceptions; +use Engelsystem\Exceptions\BasicHandler as ExceptionHandler; use Engelsystem\Exceptions\ExceptionsServiceProvider; -use Engelsystem\Exceptions\Handler as ExceptionHandler; +use Engelsystem\Exceptions\Handler; use Engelsystem\Test\Unit\ServiceProviderTest; use PHPUnit_Framework_MockObject_MockObject; @@ -18,10 +19,11 @@ class ExceptionsServiceProviderTest extends ServiceProviderTest $exceptionHandler = $this->getMockBuilder(ExceptionHandler::class) ->getMock(); - $app = $this->getApp(); + $app = $this->getApp(['make', 'instance', 'bind']); $this->setExpects($app, 'make', [ExceptionHandler::class], $exceptionHandler); $this->setExpects($app, 'instance', ['error.handler', $exceptionHandler]); + $this->setExpects($app, 'bind', [Handler::class, 'error.handler']); $serviceProvider = new ExceptionsServiceProvider($app); $serviceProvider->register(); diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php new file mode 100644 index 00000000..29759be7 --- /dev/null +++ b/tests/Unit/Exceptions/HandlerTest.php @@ -0,0 +1,38 @@ +getMockForAbstractClass(Handler::class); + $this->assertInstanceOf(Handler::class, $handler); + $handler->register(); + } + + /** + * @covers \Engelsystem\Exceptions\Handler::setEnvironment() + * @covers \Engelsystem\Exceptions\Handler::getEnvironment() + */ + public function testEnvironment() + { + /** @var Handler|Mock $handler */ + $handler = $this->getMockForAbstractClass(Handler::class); + + $handler->setEnvironment(Handler::ENV_DEVELOPMENT); + $this->assertEquals(Handler::ENV_DEVELOPMENT, $handler->getEnvironment()); + + $handler->setEnvironment(Handler::ENV_PRODUCTION); + $this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment()); + } +} -- cgit v1.2.3-54-g00ecf