/** * @param $configFile * @param Container|NULL $bootstrapContainer * @return Container */ private function createContainer($configFile, Container $bootstrapContainer = NULL) { $factory = new ContainerFactory(); $factory->addConfig($this->workingDir . '/' . $configFile); if (is_file($this->workingDir . '/config.local.neon')) { $factory->addConfig($this->workingDir . '/config.local.neon'); } $factory->setWorkingDirectory($this->workingDir); if ($bootstrapContainer !== NULL) { $factory->addContainerToMerge($bootstrapContainer); } return $factory->create(); }
public function testServices() { $workingDir = __DIR__ . '/02'; $factory = new ContainerFactory(); $factory->setWorkingDirectory($workingDir); $factory->addConfig(__DIR__ . '/02/config.neon'); $factory->addConfig(__DIR__ . '/02/config2.neon'); $cont = new Container(); $cont->addService('myService', new \StdClass()); $cont->setParameter('myContainerKey', 'myContainerValue'); $factory->addContainerToMerge($cont); $container = $factory->create(); $this->assertTrue($container->hasService('myservice')); $this->assertFalse($container->hasService('myArrayWhichDoesNotExists')); $this->assertInstanceOf('DateTime', $container->getService('myservice')); $this->assertEquals(date('Y-m-d', strtotime('+ 1 day')), $container->getService('myservice')->format('Y-m-d')); }