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

RetryStrategyLocatorFactoryTest   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\Retry;
6
7
use Laminas\ServiceManager\ServiceManager;
8
use PHPUnit\Framework\TestCase;
9
use Prophecy\PhpUnit\ProphecyTrait;
10
use Psr\Container\ContainerInterface;
11
use Symfony\Component\Messenger\Retry\RetryStrategyInterface;
12
use TMV\Laminas\Messenger\Factory\Retry\RetryStrategyLocatorFactory;
13
14
class RetryStrategyLocatorFactoryTest extends TestCase
15
{
16
    use ProphecyTrait;
17
18
    public function testFactory(): void
19
    {
20
        $container = $this->prophesize(ContainerInterface::class);
21
        $container->has('config')->willReturn(true);
22
        $container->get('config')->willReturn([
23
            'messenger' => [
24
                'transports' => [
25
                    'foo' => [
26
                        'retry_strategy' => 'foo_strategy',
27
                    ],
28
                ],
29
            ],
30
        ]);
31
32
        $strategy = $this->prophesize(RetryStrategyInterface::class);
33
        $container->get('foo_strategy')
34
            ->shouldBeCalled()
35
            ->willReturn($strategy->reveal());
36
37
        $factory = new RetryStrategyLocatorFactory();
38
        $service = $factory($container->reveal());
39
40
        $this->assertInstanceOf(ServiceManager::class, $service);
41
42
        $this->assertSame($strategy->reveal(), $service->get('foo'));
43
    }
44
}
45