expectException(HandlerNotSupportedException::class); $handler = new HandlerContainer(); $handler->getHandler('foo', 'bar'); } public function testExceptionThrownIfObjectNotFound(): void { $this->expectException(HandlerNotSupportedException::class); $handler = new HandlerContainer(); $mockHandler = $this->createMock(HandlerInterface::class); $mockHandler->method('getIntegration') ->willReturn('foo'); $mockHandler->method('getSupportedObject') ->willReturn('bogus'); $handler->registerHandler($mockHandler); $handler->getHandler('foo', 'bar'); } public function testHandlerIsRegistered(): void { $handler = new HandlerContainer(); $mockHandler = $this->createMock(HandlerInterface::class); $mockHandler->method('getIntegration') ->willReturn('foo'); $mockHandler->method('getSupportedObject') ->willReturn('bar'); $handler->registerHandler($mockHandler); $returnedHandler = $handler->getHandler('foo', 'bar'); $this->assertEquals($mockHandler, $returnedHandler); } }