Completed
Pull Request — master (#331)
by Alejandro
05:29
created

HealthActionFactoryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Rest\Action;
5
6
use Doctrine\DBAL\Connection;
7
use Doctrine\ORM\EntityManager;
8
use PHPUnit\Framework\TestCase;
9
use Psr\Log\LoggerInterface;
10
use Shlinkio\Shlink\Core\Options\AppOptions;
11
use Shlinkio\Shlink\Rest\Action;
12
use Zend\ServiceManager\ServiceManager;
13
14
class HealthActionFactoryTest extends TestCase
15
{
16
    /** @var Action\HealthActionFactory */
17
    private $factory;
18
19
    public function setUp()
20
    {
21
        $this->factory = new Action\HealthActionFactory();
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function serviceIsCreatedExtractingConnectionFromEntityManager()
28
    {
29
        $em = $this->prophesize(EntityManager::class);
30
        $conn = $this->prophesize(Connection::class);
31
32
        $getConnection = $em->getConnection()->willReturn($conn->reveal());
33
34
        $sm = new ServiceManager(['services' => [
35
            'Logger_Shlink' => $this->prophesize(LoggerInterface::class)->reveal(),
36
            AppOptions::class => $this->prophesize(AppOptions::class)->reveal(),
37
            EntityManager::class => $em->reveal(),
38
        ]]);
39
40
        $instance = ($this->factory)($sm, '');
41
42
        $this->assertInstanceOf(Action\HealthAction::class, $instance);
43
        $getConnection->shouldHaveBeenCalledOnce();
44
    }
45
}
46