getMockBuilder(ExceptionHandler::class) ->getMock(); /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ $app = $this->getMockBuilder(Application::class) ->setMethods(['make', 'instance']) ->getMock(); $app->expects($this->once()) ->method('make') ->with(ExceptionHandler::class) ->willReturn($exceptionHandler); $app->expects($this->once()) ->method('instance') ->with('error.handler', $exceptionHandler); $serviceProvider = new ExceptionsServiceProvider($app); $serviceProvider->register(); } }