/**
  * test extend application config with and without context and environment.
  *
  * @covers ::__construct
  * @covers ::extend
  * @covers ::doApplicationConfigExtend
  */
 public function testExtendApplicationConfig()
 {
     $this->application->setBB_Dir(__DIR__ . '/ConfiguratorTest_Resources/bbdir');
     $this->application->setBase_Repository(__DIR__ . '/ConfiguratorTest_Resources/repository');
     $this->application->setOverrided_Config(false);
     // Test without context and without environment
     $config = new Config($this->application->getBBDir());
     $this->assertEquals(array('parameters' => array('base_directory' => 'bbdir', 'context' => 'default', 'environment' => '')), $config->getAllSections());
     $config_builder = new Configurator($this->application, $this->bundleLoader);
     $config_builder->extend(Configurator::APPLICATION_CONFIG, $config);
     $this->assertEquals(array('parameters' => array('base_directory' => 'repository', 'context' => 'default', 'environment' => '', 'foo' => 'bar')), $config->getAllSections());
     // Test with context and without environment
     $this->application->setContext('api');
     $config = new Config($this->application->getBBDir());
     $config_builder = new Configurator($this->application, $this->bundleLoader);
     $config_builder->extend(Configurator::APPLICATION_CONFIG, $config);
     $this->assertEquals(array('parameters' => array('base_directory' => 'repository', 'context' => 'api', 'environment' => '', 'foo' => 'bar', 'bar' => 'foo')), $config->getAllSections());
     // Test with context and with environment; test also with override config setted at true
     $this->application->setContext('api');
     $this->application->setEnvironment('preprod');
     $this->application->setOverrided_Config(true);
     $config = new Config($this->application->getBBDir());
     $config_builder = new Configurator($this->application, $this->bundleLoader);
     $config_builder->extend(Configurator::APPLICATION_CONFIG, $config);
     $this->assertEquals(array('parameters' => array('context' => 'api', 'environment' => 'preprod', 'overrided_config' => true)), $config->getAllSections());
 }
示例#2
0
 /**
  * @covers ::getRegistryScope
  */
 public function testGetRegistryScopeWithContextAndEnvironment()
 {
     $this->application->setContext('api');
     $this->application->setEnvironment('preprod');
     $configurator = new Configurator($this->application, $this->bundleLoader);
     $this->assertEquals('PREFIX.api.preprod', $configurator->getRegistryScope('PREFIX', true, true));
     $this->assertEquals('PREFIX.preprod', $configurator->getRegistryScope('PREFIX', false, true));
     $this->assertEquals('PREFIX.api', $configurator->getRegistryScope('PREFIX', true, false));
     $this->assertEquals('PREFIX', $configurator->getRegistryScope('PREFIX', false, false));
 }