Ejemplo n.º 1
0
 /**
  * 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());
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 3
0
 private function generateManualBBApplication($base_directory)
 {
     $application = new ManualBBApplication();
     $application->setBase_Repository($base_directory . '/repository');
     $application->setRepository($application->getBaseRepository());
     $application->setBB_Dir($base_directory . '/backbee');
     $application->setConfig_Dir($application->getBaseRepository());
     $application->setBase_Dir($base_directory);
     return $application;
 }
Ejemplo n.º 4
0
 /**
  * Create a persistor on which we will apply our tests.
  */
 public function setUp()
 {
     $virtual_structure = array('backbee' => array('Config' => array('config.yml' => \Symfony\Component\Yaml\Yaml::dump(array('parameters' => array('hello' => 'world'))))), 'repository' => array('Config' => array('config.yml' => \Symfony\Component\Yaml\Yaml::dump(array('parameters' => array('hello' => 'backbee'))))));
     vfsStream::setup('virtual_structure', 0777, $virtual_structure);
     // create basic manual application without context and environment
     $application = new ManualBBApplication();
     $application->setBase_Repository(vfsStream::url('virtual_structure') . '/repository');
     $application->setRepository($application->getBaseRepository());
     $application->setBB_Dir(vfsStream::url('virtual_structure') . '/backbee');
     $application->setConfig_Dir($application->getBBDir() . '/Config');
     $application->setBase_Dir(vfsStream::url('virtual_structure'));
     $bundleLoader = $this->getMockBuilder('BackBee\\Bundle\\BundleLoader')->disableOriginalConstructor()->getMock();
     $this->configurator = new Configurator($application, $bundleLoader);
     $this->persistor = new Persistor($application, $this->configurator);
     $this->application = $application;
     $application->setConfig(new Config($application->getConfigDir()));
     $this->configurator->configureApplicationConfig($application->getConfig());
 }