1 | <?php |
||
11 | class MetaTagHandlersCompilerPassTest extends AbstractCompilerPassTestCase |
||
12 | { |
||
13 | public function testCompilerPassCollectsValidServices() |
||
14 | { |
||
15 | $handlerRegistry = new Definition(); |
||
16 | $this->setDefinition('netgen_open_graph.handler_registry', $handlerRegistry); |
||
17 | |||
18 | $handlerOne = new Definition(); |
||
19 | $handlerOne->addTag('netgen_open_graph.meta_tag_handler', array('alias' => 'field_type/eztext')); |
||
20 | $this->setDefinition('handler_one', $handlerOne); |
||
21 | |||
22 | $handlerTwo = new Definition(); |
||
23 | $handlerTwo->addTag('netgen_open_graph.meta_tag_handler', array('alias' => 'literal/text')); |
||
24 | $this->setDefinition('handler_two', $handlerTwo); |
||
25 | |||
26 | $this->compile(); |
||
27 | |||
28 | $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
||
29 | 'netgen_open_graph.handler_registry', |
||
30 | 'addHandler', |
||
31 | array( |
||
32 | 'field_type/eztext', |
||
33 | new Reference('handler_one'), |
||
34 | ) |
||
35 | ); |
||
36 | |||
37 | $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
||
38 | 'netgen_open_graph.handler_registry', |
||
39 | 'addHandler', |
||
40 | array( |
||
41 | 'literal/text', |
||
42 | new Reference('handler_two'), |
||
43 | ) |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException |
||
49 | * @expectedExceptionMessage netgen_open_graph.meta_tag_handler service tag needs an "alias" attribute to identify the handler. None given. |
||
50 | */ |
||
51 | public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias() |
||
52 | { |
||
53 | $handlerRegistry = new Definition(); |
||
54 | $this->setDefinition('netgen_open_graph.handler_registry', $handlerRegistry); |
||
55 | |||
56 | $handlerOne = new Definition(); |
||
57 | $handlerOne->addTag('netgen_open_graph.meta_tag_handler'); |
||
58 | $this->setDefinition('handler_one', $handlerOne); |
||
59 | |||
60 | $this->compile(); |
||
61 | |||
62 | $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
||
63 | 'netgen_open_graph.handler_registry', |
||
64 | 'addHandler', |
||
65 | array( |
||
66 | new Reference('handler_one'), |
||
67 | ) |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | protected function registerCompilerPass(ContainerBuilder $container) |
||
72 | { |
||
73 | $container->addCompilerPass(new MetaTagHandlersCompilerPass()); |
||
74 | } |
||
75 | } |
||
76 |