| @@ 19-46 (lines=28) @@ | ||
| 16 | ||
| 17 | class RegistrableServicePassTest extends \PHPUnit_Framework_TestCase |
|
| 18 | { |
|
| 19 | public function testProcess() |
|
| 20 | { |
|
| 21 | $c = new ContainerBuilder; |
|
| 22 | (new InnmindNeo4jExtension)->load([], $c); |
|
| 23 | $c->setDefinition( |
|
| 24 | 'foo', |
|
| 25 | (new Definition) |
|
| 26 | ->addTag('innmind_neo4j.identity.generator', ['class' => 'stdClass']) |
|
| 27 | ); |
|
| 28 | $this->assertSame( |
|
| 29 | null, |
|
| 30 | ($p = new RegistrableServicePass( |
|
| 31 | 'innmind_neo4j.generators', |
|
| 32 | 'innmind_neo4j.identity.generator' |
|
| 33 | )) |
|
| 34 | ->process($c) |
|
| 35 | ); |
|
| 36 | $this->assertInstanceOf(CompilerPassInterface::class, $p); |
|
| 37 | ||
| 38 | $definition = $c->getDefinition('innmind_neo4j.generators'); |
|
| 39 | $calls = $definition->getMethodCalls(); |
|
| 40 | ||
| 41 | $this->assertSame(1, count($calls)); |
|
| 42 | $this->assertSame('register', $calls[0][0]); |
|
| 43 | $this->assertSame('stdClass', $calls[0][1][0]); |
|
| 44 | $this->assertInstanceOf(Reference::class, $calls[0][1][1]); |
|
| 45 | $this->assertSame('foo', (string) $calls[0][1][1]); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @expectedException Innmind\Neo4jBundle\Exception\RuntimeException |
|
| @@ 68-95 (lines=28) @@ | ||
| 65 | ->process($c); |
|
| 66 | } |
|
| 67 | ||
| 68 | public function testProcessRepositoryFactoryConfigurator() |
|
| 69 | { |
|
| 70 | $c = new ContainerBuilder; |
|
| 71 | (new InnmindNeo4jExtension)->load([], $c); |
|
| 72 | $c->setDefinition( |
|
| 73 | 'foo', |
|
| 74 | (new Definition) |
|
| 75 | ->addTag('innmind_neo4j.repository', ['class' => 'stdClass']) |
|
| 76 | ); |
|
| 77 | $this->assertSame( |
|
| 78 | null, |
|
| 79 | ($p = new RegistrableServicePass( |
|
| 80 | 'innmind_neo4j.repository_factory.configurator', |
|
| 81 | 'innmind_neo4j.repository' |
|
| 82 | )) |
|
| 83 | ->process($c) |
|
| 84 | ); |
|
| 85 | $this->assertInstanceOf(CompilerPassInterface::class, $p); |
|
| 86 | ||
| 87 | $definition = $c->getDefinition('innmind_neo4j.repository_factory.configurator'); |
|
| 88 | $calls = $definition->getMethodCalls(); |
|
| 89 | ||
| 90 | $this->assertSame(1, count($calls)); |
|
| 91 | $this->assertSame('register', $calls[0][0]); |
|
| 92 | $this->assertSame('stdClass', $calls[0][1][0]); |
|
| 93 | $this->assertInstanceOf(Reference::class, $calls[0][1][1]); |
|
| 94 | $this->assertSame('foo', (string) $calls[0][1][1]); |
|
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * @expectedException Innmind\Neo4jBundle\Exception\RuntimeException |
|