1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Tests\Innmind\Neo4jBundle\DependencyInjection\Compiler; |
5
|
|
|
|
6
|
|
|
use Innmind\Neo4jBundle\{ |
7
|
|
|
DependencyInjection\Compiler\InjectEntityDefinitionsPass, |
8
|
|
|
DependencyInjection\InnmindNeo4jExtension |
9
|
|
|
}; |
10
|
|
|
use Tests\Innmind\Neo4jBundle\{ |
11
|
|
|
Fixture\FooBundle\FooBundle, |
12
|
|
|
Fixture\BarBundle\BarBundle, |
13
|
|
|
Fixture\EmptyBundle\EmptyBundle |
14
|
|
|
}; |
15
|
|
|
use Innmind\Neo4j\ONM\Identity\Uuid; |
16
|
|
|
use Symfony\Component\DependencyInjection\{ |
17
|
|
|
ContainerBuilder, |
18
|
|
|
Compiler\CompilerPassInterface |
19
|
|
|
}; |
20
|
|
|
|
21
|
|
|
class InjectEntityDefinitionsPassTest extends \PHPUnit_Framework_TestCase |
22
|
|
|
{ |
23
|
|
|
public function testProcess() |
24
|
|
|
{ |
25
|
|
|
$c = new ContainerBuilder; |
26
|
|
|
$c->setParameter( |
27
|
|
|
'kernel.bundles', |
28
|
|
|
[ |
29
|
|
|
'FixtureFooBundle' => FooBundle::class, |
30
|
|
|
'FixtureBarBundle' => BarBundle::class, |
31
|
|
|
'FixtureEmptyBundle' => EmptyBundle::class, |
32
|
|
|
] |
33
|
|
|
); |
34
|
|
|
(new InnmindNeo4jExtension)->load([], $c); |
35
|
|
|
$this->assertSame( |
36
|
|
|
null, |
37
|
|
|
($p = new InjectEntityDefinitionsPass)->process($c) |
38
|
|
|
); |
39
|
|
|
$this->assertInstanceOf(CompilerPassInterface::class, $p); |
40
|
|
|
|
41
|
|
|
$def = $c->getDefinition('innmind_neo4j.metadata_builder'); |
42
|
|
|
$calls = $def->getMethodCalls(); |
43
|
|
|
|
44
|
|
|
$this->assertSame(1, count($calls)); |
45
|
|
|
$this->assertSame('inject', $calls[0][0]); |
46
|
|
|
$this->assertSame( |
47
|
|
|
[ |
48
|
|
|
[ |
49
|
|
|
'Foo' => [ |
50
|
|
|
'type' => 'aggregate', |
51
|
|
|
'identity' => [ |
52
|
|
|
'property' => 'uuid', |
53
|
|
|
'type' => Uuid::class, |
54
|
|
|
], |
55
|
|
|
], |
56
|
|
|
], |
57
|
|
|
[ |
58
|
|
|
'Bar' => [ |
59
|
|
|
'type' => 'relationship', |
60
|
|
|
'identity' => [ |
61
|
|
|
'property' => 'uuid', |
62
|
|
|
'type' => Uuid::class, |
63
|
|
|
], |
64
|
|
|
'rel_type' => 'BAR', |
65
|
|
|
'startNode' => [ |
66
|
|
|
'property' => 'start', |
67
|
|
|
'type' => Uuid::class, |
68
|
|
|
'target' => 'uuid', |
69
|
|
|
], |
70
|
|
|
'endNode' => [ |
71
|
|
|
'property' => 'end', |
72
|
|
|
'type' => Uuid::class, |
73
|
|
|
'target' => 'uuid', |
74
|
|
|
], |
75
|
|
|
], |
76
|
|
|
], |
77
|
|
|
], |
78
|
|
|
$calls[0][1][0] |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|