Completed
Push — develop ( ae636a...0d7fb1 )
by Alejandro
21s queued 14s
created

setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Core\EventDispatcher;
6
7
use PHPUnit\Framework\TestCase;
8
use Prophecy\PhpUnit\ProphecyTrait;
9
use Prophecy\Prophecy\ObjectProphecy;
10
use Psr\Container\ContainerInterface;
11
use Shlinkio\Shlink\Common\Doctrine\ReopeningEntityManagerInterface;
12
use Shlinkio\Shlink\Core\EventDispatcher\CloseDbConnectionEventListenerDelegator;
13
14
class CloseDbConnectionEventListenerDelegatorTest extends TestCase
15
{
16
    use ProphecyTrait;
17
18
    private CloseDbConnectionEventListenerDelegator $delegator;
19
    private ObjectProphecy $container;
20
21
    public function setUp(): void
22
    {
23
        $this->container = $this->prophesize(ContainerInterface::class);
24
        $this->delegator = new CloseDbConnectionEventListenerDelegator();
25
    }
26
27
    /** @test */
28
    public function properDependenciesArePassed(): void
29
    {
30
        $callbackInvoked = false;
31
        $callback = function () use (&$callbackInvoked): callable {
32
            $callbackInvoked = true;
33
34
            return function (): void {
35
            };
36
        };
37
38
        $em = $this->prophesize(ReopeningEntityManagerInterface::class);
39
        $getEm = $this->container->get('em')->willReturn($em->reveal());
40
41
        ($this->delegator)($this->container->reveal(), '', $callback);
42
43
        self::assertTrue($callbackInvoked);
44
        $getEm->shouldHaveBeenCalledOnce();
45
    }
46
}
47