Completed
Pull Request — master (#51)
by Robin
02:45
created

ContainerBasedHandlerLocatorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 29
rs 10
c 1
b 0
f 0

2 Methods

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