/** * 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()); }
/** * @covers ::deleteSection * @covers ::deleteAllSections */ public function testDeleteSection() { // init test environment $config = new Config($this->test_base_dir); $parameters_section_settings = array('foo' => 'bar'); $config->setSection('parameters', $parameters_section_settings); // pre test $this->assertTrue($config->getSection('say') !== null); $this->assertEquals(array_merge(array('say' => $config->getSection('say')), array('parameters' => $parameters_section_settings)), $config->getAllSections()); // call action to test $config->deleteSection('say'); // post test $this->assertFalse($config->getSection('say') !== null); $this->assertEquals(array('parameters' => $parameters_section_settings), $config->getAllSections()); // second test $config->deleteAllSections(); $this->assertEmpty($config->getAllSections()); }