예제 #1
0
 public function testNotDumpableService()
 {
     $id = 'not.dumpable_service';
     $definition = new Definition();
     $definition->setClass('DateTime');
     $definition->addTag('dumpable');
     $definition->addArgument('now');
     $definition->addArgument(new Reference('timezone'));
     $this->container->setDefinition($id, $definition);
     $not_dumpable_service = $this->container->get($id);
     try {
         $this->dumper->dump();
         $this->fail('Raise of ServiceNotDumpableException expected.');
     } catch (\Exception $e) {
         $this->assertInstanceOf('BackBee\\DependencyInjection\\Exception\\ServiceNotDumpableException', $e);
     }
 }
예제 #2
0
 /**
  * Try to parse a yaml config file.
  *
  * @param string $filename
  *
  * @throws \BackBee\Config\Exception\InvalidConfigException Occurs when the file can't be parsed
  */
 private function loadFromFile($filename, $overwrite = false)
 {
     try {
         $yamlDatas = Yaml::parse(file_get_contents($filename));
         if (is_array($yamlDatas)) {
             if (true === $this->debug) {
                 $this->debug_data[$filename] = $yamlDatas;
             }
             if (self::CONFIG_FILE . '.' . self::EXTENSION === basename($filename) || self::CONFIG_FILE . '.' . $this->environment . '.' . self::EXTENSION === basename($filename)) {
                 foreach ($yamlDatas as $component => $config) {
                     if (!is_array($config)) {
                         $this->container->get('logger')->error('Bad configuration, array expected, given : ' . $config);
                     }
                     $this->setSection($component, $config, $overwrite);
                 }
             } else {
                 $this->setSection(basename($filename, '.' . self::EXTENSION), $yamlDatas, $overwrite);
             }
         }
     } catch (ParseException $e) {
         throw new InvalidConfigException($e->getMessage(), null, $e, $e->getParsedFile(), $e->getParsedLine());
     }
 }
 /**
  * test that the load of backbee core services and repository services are done is the right order.
  *
  * @depends testHydrateContainerWithBootstrapParameters
  *
  * @covers ::loadApplicationServices
  */
 public function testLoadApplicationServices(Container $container)
 {
     $this->assertEquals('foo', $container->getParameter('foo'));
     $this->assertEquals('BackBee\\Logging\\Logger', $container->getParameter('bbapp.logger.class'));
     $this->assertEquals('BackBee\\Logging\\DebugStackLogger', $container->getParameter('bbapp.logger_debug.class'));
     $this->assertInstanceOf('DateTime', $container->get('core_service'));
     $this->assertInstanceOf('DateTime', $container->get('repository_service'));
     $this->assertNull($container->get('synthetic_service'));
     $this->assertTrue($container->getDefinition('synthetic_service')->isSynthetic());
     return $container;
 }