Spaces:
No application file
No application file
mautic
/
app
/bundles
/IntegrationsBundle
/Tests
/Unit
/Sync
/Notification
/Handler
/HandlerContainerTest.php
declare(strict_types=1); | |
namespace Mautic\IntegrationsBundle\Tests\Unit\Sync\Notification\Handler; | |
use Mautic\IntegrationsBundle\Sync\Exception\HandlerNotSupportedException; | |
use Mautic\IntegrationsBundle\Sync\Notification\Handler\HandlerContainer; | |
use Mautic\IntegrationsBundle\Sync\Notification\Handler\HandlerInterface; | |
use PHPUnit\Framework\TestCase; | |
class HandlerContainerTest extends TestCase | |
{ | |
public function testExceptionThrownIfIntegrationNotFound(): void | |
{ | |
$this->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); | |
} | |
} | |