public function testCompile() { $this->_mockLogger->shouldReceive('error')->once()->with('Failed to inspect <code>bogus class</code>: <code>Class bogus class does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('Failed to inspect <code>Hello</code>: <code>Class Hello does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('Failed to inspect <code>There</code>: <code>Class There does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('(Add-on <code>1</code> of <code>2</code>: <code>mock add-on 1</code>) Failed to load <code>bogus class</code> as a container extension: <code>Class bogus class does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('(Add-on <code>2</code> of <code>2</code>: <code>mock add-on 2</code>) Failed to load <code>Hello</code> as a container extension: <code>Class Hello does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('(Add-on <code>2</code> of <code>2</code>: <code>mock add-on 2</code>) Failed to load <code>There</code> as a container extension: <code>Class There does not exist</code>'); $this->_mockLogger->shouldReceive('error')->once()->with('Failed to load <code>no such class</code> as a compiler pass: <code>Class no such class does not exist</code>'); $mockAddon1 = $this->mock(tubepress_api_contrib_AddonInterface::_); $mockAddon2 = $this->mock(tubepress_api_contrib_AddonInterface::_); $mockAddon1->shouldReceive('getName')->andReturn('mock add-on 1'); $mockAddon2->shouldReceive('getName')->andReturn('mock add-on 2'); $mockAddon1IocContainerExtensions = array('FakeExtension', 'bogus class'); $mockAddon2IocContainerExtensions = array('Hello', 'There'); $mockAddon2IocCompilerPasses = array('FakeCompilerPass' => 5, 'no such class' => 4); $mockAddon1->shouldReceive('getExtensionClassNames')->once()->andReturn($mockAddon1IocContainerExtensions); $mockAddon1->shouldReceive('getMapOfCompilerPassClassNamesToPriorities')->once()->andReturn(array()); $mockAddon2->shouldReceive('getExtensionClassNames')->once()->andReturn($mockAddon2IocContainerExtensions); $mockAddon2->shouldReceive('getMapOfCompilerPassClassNamesToPriorities')->once()->andReturn($mockAddon2IocCompilerPasses); $mockAddons = array($mockAddon1, $mockAddon2); $this->_mockIocContainer->shouldReceive('compile')->once(); $this->_mockIocContainer->shouldReceive('addCompilerPass')->once()->with(Mockery::any('FakeCompilerPass')); $this->_mockIocContainer->shouldReceive('registerExtension')->once()->with(Mockery::any('FakeExtension')); $this->_sut->compile($this->_mockIocContainer, $mockAddons); $this->assertTrue(true); }
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); }