Passed
Push — master ( b2b84f...109e7c )
by Thomas Mauro
03:02
created

HandlersLocatorFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 31
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Laminas\Messenger\Test\Factory\Handler;
6
7
use PHPUnit\Framework\TestCase;
8
use Prophecy\PhpUnit\ProphecyTrait;
9
use Psr\Container\ContainerInterface;
10
use Symfony\Component\Messenger\Handler\HandlerDescriptor;
11
use Symfony\Component\Messenger\Handler\HandlersLocator;
12
use Symfony\Component\Messenger\Handler\HandlersLocatorInterface;
13
use TMV\Laminas\Messenger\Factory\Handler\HandlersLocatorFactory;
14
15
class HandlersLocatorFactoryTest extends TestCase
16
{
17
    use ProphecyTrait;
18
19
    public function testFactory(): void
20
    {
21
        $factory = new HandlersLocatorFactory('bus_name');
22
23
        $container = $this->prophesize(ContainerInterface::class);
24
        $container->has('config')->willReturn(true);
25
        $container->get('config')->willReturn([
26
            'messenger' => [
27
                'buses' => [
28
                    'bus_name' => [
29
                        'handlers' => [
30
                            'foo' => [
31
                                'handler1',
32
                                static function () {},
33
                                new HandlerDescriptor(static function () {}),
34
                            ],
35
                        ],
36
                    ],
37
                ],
38
            ],
39
        ]);
40
        /** @var HandlersLocator $service */
41
        $service = $factory($container->reveal());
42
43
        $this->assertInstanceOf(HandlersLocatorInterface::class, $service);
44
    }
45
}
46