public function getNewSymfonyContainer()
 {
     if (!isset($this->_containerBuilder)) {
         $this->_containerBuilder = new tubepress_internal_ioc_ContainerBuilder();
     }
     $this->_containerBuilder->set('tubepress_api_ioc_ContainerInterface', $this->_containerBuilder);
     $this->_containerBuilder->set('symfony_service_container', $this->_containerBuilder->getDelegateContainerBuilder());
     $this->_containerBuilder->set('tubepress_internal_logger_BootLogger', $this->_logger);
     $this->_containerBuilder->set(tubepress_api_boot_BootSettingsInterface::_, $this->_bootSettings);
     $addons = $this->_findAllAddons();
     if ($this->_bootSettings->isClassLoaderEnabled()) {
         $this->_setupClassLoader($addons);
     }
     $this->_iocCompiler->compile($this->_containerBuilder, $addons);
     if ($this->_bootSettings->isClassLoaderEnabled()) {
         spl_autoload_unregister(array($this->_mapClassLoader, 'loadClass'));
     }
     return $this->_convertToSymfonyContainer($this->_containerBuilder);
 }
 public function testLoad()
 {
     $this->prepareForLoad();
     $this->_sut->load($this->_mockContainer);
     $realContainerBuilder = new tubepress_internal_ioc_ContainerBuilder();
     $realContainerBuilder->registerExtension($this->_sut);
     foreach ($this->getExpectedExternalServicesMap() as $id => $type) {
         if (is_string($type)) {
             $realContainerBuilder->set($id, $this->mock($type));
         } else {
             $realContainerBuilder->set($id, $type);
         }
     }
     foreach ($this->getExpectedParameterMap() as $key => $value) {
         $realContainerBuilder->setParameter($key, $value);
     }
     foreach ($this->_expectedDecoratedServices as $serviceId) {
         $decoratedDefinition = new tubepress_internal_ioc_Definition($serviceId);
         $decoratedDefinition->setFactoryClass('Mockery');
         $decoratedDefinition->setFactoryMethod('mock');
         $decoratedDefinition->addArgument($serviceId);
         $realContainerBuilder->setDefinition(strtolower($serviceId), $decoratedDefinition);
     }
     $this->preCompile($realContainerBuilder);
     $realContainerBuilder->compile();
     $this->postCompile($realContainerBuilder);
     foreach ($this->_expectedServiceConstructions as $id => $type) {
         $this->assertTrue($realContainerBuilder->hasDefinition($id), "Expected that container has definition for {$id}");
         $this->assertTrue($realContainerBuilder->has($id), "Expected that container has definition for {$id}");
         $service = $realContainerBuilder->get($id);
         if (is_string($type)) {
             $this->assertInstanceOf($type, $service, "{$id} is not an instance of {$type} (actually is " . get_class($service) . ')');
         } else {
             /**
              * @var $def tubepress_api_ioc_DefinitionInterface
              */
             $def = $type;
             $this->assertInstanceOf($def->getClass(), $service);
         }
     }
 }
Пример #3
0
 public function testSetService()
 {
     $service = new stdClass();
     $this->_sut->set('x', $service);
     $this->assertSame($service, $this->_sut->get('x'));
 }