Completed
Push — master ( 0456c5...25ee32 )
by Oleg
04:45
created

SimpleRegistryTestCest::testReset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace codecept\Doctrine;
5
6
use codecept\FunctionalTester;
7
use codecept\Helper\ZendExpressive3;
8
use Doctrine\DBAL\Driver\Connection;
9
use SlayerBirden\DataFlowServer\Doctrine\Persistence\EntityManagerRegistry;
10
11
class SimpleRegistryTestCest
12
{
13
    /**
14
     * @var ZendExpressive3
15
     */
16
    private $expressive;
17
    /**
18
     * @var EntityManagerRegistry
19
     */
20
    private $registry;
21
22
    public function _inject(ZendExpressive3 $expressive)
23
    {
24
        $this->expressive = $expressive;
25
    }
26
27
    public function _before(FunctionalTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
28
    {
29
        $this->registry = $this->expressive->container->get(EntityManagerRegistry::class);
30
    }
31
32
    public function testReset(FunctionalTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
33
    {
34
        $manager = $this->registry->getManager();
35
        $I->assertTrue($manager->isOpen());
36
37
        $manager->close(); // close manager
38
        $I->assertFalse($manager->isOpen());
39
40
        $newManager = $this->registry->getManager();
41
        $I->assertTrue($newManager->isOpen());
42
    }
43
44
    public function testGetConnection(FunctionalTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
45
    {
46
        $connection = $this->registry->getConnection();
47
        $I->assertInstanceOf(Connection::class, $connection);
48
    }
49
50
    public function testGetConnections(FunctionalTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
51
    {
52
        $connections = $this->registry->getConnections();
53
        $I->assertNotEmpty($connections);
54
    }
55
56
    public function testGetManagers(FunctionalTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
57
    {
58
        $managers = $this->registry->getManagers();
59
        $I->assertNotEmpty($managers);
60
    }
61
62
    public function testGetManagerWrongName(FunctionalTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
63
    {
64
        $I->expectException(
65
            new \InvalidArgumentException('Could not find Doctrine manager with name bar123'),
66
            function () {
67
                $this->registry->getManager('bar123');
68
            }
69
        );
70
    }
71
}
72