Completed
Push — develop ( 7f6ad2...eb155e )
by Baptiste
02:38
created

InnmindNeo4jExtensionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 21
cp 0
rs 9.2
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Neo4jBundle\DependencyInjection;
5
6
use Innmind\Neo4jBundle\DependencyInjection\InnmindNeo4jExtension;
7
use Innmind\Neo4j\DBAL\{
8
    Server,
9
    Authentication
10
};
11
use Symfony\Component\DependencyInjection\{
12
    ContainerBuilder,
13
    Reference
14
};
15
16
class InnmindNeo4jExtensionTest extends \PHPUnit_Framework_TestCase
17
{
18
    private $c;
19
    private $e;
20
21
    public function setUp()
22
    {
23
        $this->c = new ContainerBuilder;
24
        $this->e = new InnmindNeo4jExtension;
25
        $config = [
26
            'innmind_neo4j' => [
27
                'connection' => [
28
                    'scheme' => 'http',
29
                    'host' => 'docker',
30
                    'port' => 1337,
31
                    'timeout' => 42,
32
                    'user' => 'neo4j',
33
                    'password' => 'ci',
34
                ],
35
                'types' => ['foo', 'bar'],
36
                'persister' => 'another_service',
37
                'metadata_configuration' => 'config',
38
            ],
39
        ];
40
41
        $this->e->load($config, $this->c);
42
    }
43
44 View Code Duplication
    public function testPersister()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $def = $this->c->getDefinition('innmind_neo4j.unit_of_work');
47
48
        $this->assertInstanceOf(Reference::class, $def->getArgument(5));
49
        $this->assertSame('another_service', (string) $def->getArgument(5));
50
    }
51
52
    public function testConnection()
53
    {
54
        $def = $this->c->getDefinition('innmind_neo4j.connection.server');
55
        $this->assertSame('http', $def->getArgument(0));
56
        $this->assertSame('docker', $def->getArgument(1));
57
        $this->assertSame(1337, $def->getArgument(2));
58
59
        $def = $this->c->getDefinition('innmind_neo4j.connection.authentication');
60
        $this->assertSame('neo4j', $def->getArgument(0));
61
        $this->assertSame('ci', $def->getArgument(1));
62
63
        $def = $this->c->getDefinition('innmind_neo4j.connection.transactions');
64
        $this->assertSame(42, $def->getArgument(2));
65
66
        $transport = $this->c->getDefinition('innmind_neo4j.connection.transport');
67
        $this->assertSame(42, $transport->getArgument(4));
68
    }
69
70
    public function testTypes()
71
    {
72
        $def = $this->c->getDefinition('innmind_neo4j.types');
73
        $calls = $def->getMethodCalls();
74
75
        $this->assertSame(2, count($calls));
76
        $this->assertSame('register', $calls[0][0]);
77
        $this->assertSame('foo', $calls[0][1][0]);
78
        $this->assertSame('register', $calls[1][0]);
79
        $this->assertSame('bar', $calls[1][1][0]);
80
    }
81
82 View Code Duplication
    public function testMetadataConfiguration()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
    {
84
        $def = $this->c->getDefinition('innmind_neo4j.metadata_builder');
85
86
        $this->assertInstanceOf(Reference::class, $def->getArgument(2));
87
        $this->assertSame('config', (string) $def->getArgument(2));
88
    }
89
90 View Code Duplication
    public function testDefaultPersister()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
    {
92
        $c = new ContainerBuilder;
93
        $this->e->load([], $c);
94
        $def = $c->getDefinition('innmind_neo4j.unit_of_work');
95
96
        $this->assertInstanceOf(Reference::class, $def->getArgument(5));
97
        $this->assertSame(
98
            'innmind_neo4j.persister.delegation',
99
            (string) $def->getArgument(5)
100
        );
101
    }
102
103
    public function testDefaultConnection()
104
    {
105
        $c = new ContainerBuilder;
106
        $this->e->load([], $c);
107
108
        $def = $this->c->getDefinition('innmind_neo4j.connection.server');
109
        $this->assertSame('http', $def->getArgument(0));
110
        $this->assertSame('docker', $def->getArgument(1));
111
        $this->assertSame(1337, $def->getArgument(2));
112
113
        $def = $this->c->getDefinition('innmind_neo4j.connection.authentication');
114
        $this->assertSame('neo4j', $def->getArgument(0));
115
        $this->assertSame('ci', $def->getArgument(1));
116
117
        $def = $c->getDefinition('innmind_neo4j.connection.transactions');
118
        $this->assertSame(60, $def->getArgument(2));
119
120
        $transport = $c->getDefinition('innmind_neo4j.connection.transport');
121
        $this->assertSame(60, $transport->getArgument(4));
122
    }
123
124
    public function testDefaultTypes()
125
    {
126
        $c = new ContainerBuilder;
127
        $this->e->load([], $c);
128
        $def = $c->getDefinition('innmind_neo4j.types');
129
        $calls = $def->getMethodCalls();
130
131
        $this->assertSame(0, count($calls));
132
    }
133
134 View Code Duplication
    public function testDefaultMetadataConfiguration()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
135
    {
136
        $c = new ContainerBuilder;
137
        $this->e->load([], $c);
138
        $def = $c->getDefinition('innmind_neo4j.metadata_builder');
139
140
        $this->assertInstanceOf(Reference::class, $def->getArgument(2));
141
        $this->assertSame('innmind_neo4j.metadata_builder.configuration', (string) $def->getArgument(2));
142
    }
143
}
144