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

DoctrineTransactionMiddlewareFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Laminas\Messenger\Test\Factory\Middleware;
6
7
use Doctrine\Persistence\ManagerRegistry;
8
use PHPUnit\Framework\TestCase;
9
use Prophecy\PhpUnit\ProphecyTrait;
10
use Psr\Container\ContainerInterface;
11
use TMV\Laminas\Messenger\Exception\InvalidArgumentException;
12
use TMV\Laminas\Messenger\Factory\Middleware\DoctrineTransactionMiddlewareFactory;
13
use TMV\Laminas\Messenger\Middleware\DoctrineTransactionMiddleware;
14
15
class DoctrineTransactionMiddlewareFactoryTest extends TestCase
16
{
17
    use ProphecyTrait;
18
19
    public function testFactory(): void
20
    {
21
        $container = $this->prophesize(ContainerInterface::class);
22
        $managerRegistry = $this->prophesize(ManagerRegistry::class);
23
24
        $container->get(ManagerRegistry::class)
25
            ->shouldBeCalled()
26
            ->willReturn($managerRegistry->reveal());
27
28
        $factory = [DoctrineTransactionMiddlewareFactory::class, 'connection_name'];
29
        $service = $factory($container->reveal());
30
31
        $this->assertInstanceOf(DoctrineTransactionMiddleware::class, $service);
32
    }
33
34
    public function testInvalidCall(): void
35
    {
36
        $this->expectException(InvalidArgumentException::class);
37
38
        $factory = [DoctrineTransactionMiddlewareFactory::class, 'connection_name'];
39
        $factory('foo');
40
    }
41
}
42