| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the LegacyStorageEnginePassTest class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Symfony\Component\DependencyInjection\ContainerBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Symfony\Component\DependencyInjection\Definition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\DependencyInjection\Reference; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class LegacyStorageEnginePassTest extends AbstractCompilerPassTestCase | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     protected function setUp() | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         parent::setUp(); | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         $this->setDefinition('ezpublish.api.storage_engine.legacy.factory', new Definition()); | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * Register the compiler pass under test, just like you would do inside a bundle's load() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * method:. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      *   $container->addCompilerPass(new MyCompilerPass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     protected function registerCompilerPass(ContainerBuilder $container) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $container->addCompilerPass(new LegacyStorageEnginePass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function testRegisterFieldType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $def->addTag('ezpublish.fieldType', array('alias' => $fieldTypeIdentifier)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             'registerFieldType', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             array($serviceId, $fieldTypeIdentifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @expectedException \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     public function testRegisterFieldTypeNoAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $def->addTag('ezpublish.fieldType'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             'registerFieldType', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             array($serviceId, $fieldTypeIdentifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 81 |  | View Code Duplication |     public function testRegisterConverter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $class = 'Some\Class'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $callback = '::foobar'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $def->setClass($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $def->addTag( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             'ezpublish.storageEngine.legacy.converter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 'alias' => $fieldTypeIdentifier, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                 'lazy' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                 'callback' => $callback, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             'registerFieldTypeConverter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             array($fieldTypeIdentifier, $class . $callback) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @expectedException \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 114 |  | View Code Duplication |     public function testRegisterConverterNoAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $class = 'Some\Class'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $callback = '::foobar'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $def->setClass($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $def->addTag( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             'ezpublish.storageEngine.legacy.converter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 'lazy' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 'callback' => $callback, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             'registerFieldTypeConverter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             array($fieldTypeIdentifier, $class . $callback) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * @expectedException \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 146 |  | View Code Duplication |     public function testRegisterConverterLazyNoCallback() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         $class = 'Some\Class'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $callback = '::foobar'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $def->setClass($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         $def->addTag( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             'ezpublish.storageEngine.legacy.converter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 'alias' => $fieldTypeIdentifier, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 'lazy' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             'registerFieldTypeConverter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             array($fieldTypeIdentifier, $class . $callback) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @covers \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\LegacyStorageEnginePass::process | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 176 |  | View Code Duplication |     public function testRegisterConverterNoLazy() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $fieldTypeIdentifier = 'fieldtype_identifier'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $serviceId = 'some_service_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $class = 'Some\Class'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $def = new Definition(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         $def->setClass($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $def->addTag( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             'ezpublish.storageEngine.legacy.converter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             array('alias' => $fieldTypeIdentifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $this->setDefinition($serviceId, $def); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $this->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             'ezpublish.api.storage_engine.legacy.factory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             'registerFieldTypeConverter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             array($fieldTypeIdentifier, new Reference($serviceId)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 198 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 199 |  |  |  |