public function testBuild() { $bundle = new BotanickSerializerBundle(); $containerBuilder = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->disableOriginalConstructor()->setMethods(array('addCompilerPass'))->getMock(); $that = $this; $containerBuilder->expects($this->once())->method('addCompilerPass')->willReturnCallback(function (CompilerPassInterface $pass) use($that) { $that->assertInstanceOf('Botanick\\SerializerBundle\\DependencyInjection\\Compiler\\DataSerializerCompilerPass', $pass); }); /** @var ContainerBuilder $containerBuilder */ $bundle->build($containerBuilder); }
/** * @param string $configFilename * @return ContainerBuilder */ private function getContainerForConfig($configFilename) { $container = new ContainerBuilder(new ParameterBag(array('kernel.debug' => true, 'kernel.cache_dir' => self::$_cacheDir, 'kernel.name' => 'App', 'kernel.environment' => 'test', 'kernel.bundles' => array('BotanickSerializerBundle' => 'Botanick\\SerializerBundle\\BotanickSerializerBundle')))); $fileLocator = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Config\\FileLocator')->disableOriginalConstructor()->getMock(); $container->set('file_locator', $fileLocator); $container->registerExtension(new BotanickSerializerExtension()); $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Fixtures/config')); $loader->load($configFilename . '.yml'); $bundle = new BotanickSerializerBundle(); $bundle->build($container); $container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); return $container; }