EntityManagerPoolTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Doctrine\Test\Unit\Business\Pool;
15
16
use Micro\Plugin\Doctrine\Business\EntityManager\EntityManagerFactoryInterface;
17
use Micro\Plugin\Doctrine\Business\Pool\EntityManagerPool;
18
use Micro\Plugin\Doctrine\Business\Pool\EntityManagerPoolInterface;
19
use PHPUnit\Framework\TestCase;
20
21
class EntityManagerPoolTest extends TestCase
22
{
23
    private EntityManagerPoolInterface $pool;
24
    private EntityManagerFactoryInterface $emFactory;
25
26
    protected function setUp(): void
27
    {
28
        $this->emFactory = $this->createMock(EntityManagerFactoryInterface::class);
29
30
        $this->pool = new EntityManagerPool(
31
            $this->emFactory,
32
            [],
33
        );
34
    }
35
36
    public function testGetDefaultManager()
37
    {
38
        $this->expectException(\LogicException::class);
39
        $this->pool->getDefaultManager();
40
    }
41
42
    public function testGetManager()
43
    {
44
        $this->emFactory
45
            ->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Micro\Plugin\Doctrine\Bu...ManagerFactoryInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
            ->/** @scrutinizer ignore-call */ 
46
              expects($this->once())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
            ->method('create')
47
            ->with('default');
48
49
        $manager = $this->pool->getManager('default');
50
        $cached = $this->pool->getManager('default');
51
52
        $this->assertEquals($manager, $cached);
53
    }
54
}
55