Passed
Pull Request — master (#437)
by Alejandro
09:16
created

decoratesEntityManagerFromCallback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\Doctrine;
5
6
use Doctrine\ORM\EntityManagerInterface;
7
use PHPUnit\Framework\TestCase;
8
use ReflectionObject;
9
use Shlinkio\Shlink\Common\Doctrine\ReopeningEntityManagerDelegator;
10
use Zend\ServiceManager\ServiceManager;
11
12
class ReopeningEntityManagerDelegatorTest extends TestCase
13
{
14
    /** @test */
15
    public function decoratesEntityManagerFromCallback(): void
16
    {
17
        $em = $this->prophesize(EntityManagerInterface::class)->reveal();
18
        $result = (new ReopeningEntityManagerDelegator())(new ServiceManager(), '', function () use ($em) {
19
            return $em;
20
        });
21
22
        $ref = new ReflectionObject($result);
23
        $prop = $ref->getProperty('wrapped');
24
        $prop->setAccessible(true);
25
26
        $this->assertSame($em, $prop->getValue($result));
27
    }
28
}
29