ContainerBasedHandlerLocatorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetHandler() 0 13 1
A testGetHandlerThrowsExceptionForNotFound() 0 10 1
1
<?php
2
3
namespace League\Tactician\Bundle\Tests\Handler;
4
5
use League\Tactician\Bundle\Handler\ContainerBasedHandlerLocator;
6
use League\Tactician\Exception\MissingHandlerException;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
class ContainerBasedHandlerLocatorTest extends TestCase
11
{
12
    public function testGetHandler()
13
    {
14
        $container = new ContainerBuilder();
15
        $container->register('fake_command_handler', 'stdClass')->setPublic(true);
16
        $container->compile();
17
18
        $locator = new ContainerBasedHandlerLocator($container, [
19
            'FakeCommand' => 'fake_command_handler',
20
            'OtherCommand' => 'other_command_handler'
21
        ]);
22
23
        $this->assertInstanceOf('stdClass', $locator->getHandlerForCommand('FakeCommand'));
24
    }
25
26
    public function testGetHandlerThrowsExceptionForNotFound()
27
    {
28
        $this->expectException(MissingHandlerException::class);
29
30
        $locator = new ContainerBasedHandlerLocator(new ContainerBuilder(), [
31
            'OtherCommand' => 'my_bundle.order.id'
32
        ]);
33
34
        $locator->getHandlerForCommand('MyFakeCommand');
35
    }
36
37
}
38