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

TransportFactoryFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Laminas\Messenger\Test\Factory\Transport;
6
7
use PHPUnit\Framework\TestCase;
8
use Prophecy\PhpUnit\ProphecyTrait;
9
use Psr\Container\ContainerInterface;
10
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
11
use TMV\Laminas\Messenger\Factory\Transport\TransportFactoryFactory;
12
13
class TransportFactoryFactoryTest extends TestCase
14
{
15
    use ProphecyTrait;
16
17
    public function testFactory(): void
18
    {
19
        $container = $this->prophesize(ContainerInterface::class);
20
        $container->get('config')->willReturn([
21
            'messenger' => [
22
                'transport_factories' => [
23
                    'foo_factory',
24
                ],
25
            ],
26
        ]);
27
28
        $fooFactory = $this->prophesize(TransportFactoryInterface::class);
29
        $fooFactory->supports('foo', [])->willReturn(true);
30
        $fooFactory->supports('bar', [])->willReturn(false);
31
32
        $container->get('foo_factory')
33
            ->shouldBeCalled()
34
            ->willReturn($fooFactory->reveal());
35
36
        $factory = new TransportFactoryFactory();
37
38
        $service = $factory($container->reveal());
39
40
        $this->assertTrue($service->supports('foo', []));
41
        $this->assertFalse($service->supports('bar', []));
42
    }
43
}
44