/** * Test if we get pack right config if a default config was * set before. It should merge the config together, but the * config, which was set by the request will overwrite the default * config * */ function testMergingWithDefaultConfig() { $request = $this->createRequestMockWithConfig(['level1' => ['level2' => ['level3' => null, 'other' => 'otherValue']]]); $default = array('type' => 'defaultType', 'level1' => array('level2' => array('level3' => 'notWorth', 'type' => 'defaultLevel2Type'))); /** * both array should be merged together to this * * array( * 'type' => 'defaultType', * 'level1' => array( * 'level2' => array( * 'level3' => null, * 'type' => 'defaultLevel2Type', * 'other' => 'otherValue' * ) * ) * ); * */ $configParser = new ConfigParser(); $configParser->parse($request); $configParser->setDefault($default); $this->assertEquals('defaultType', $configParser->get('type')); $this->assertArraySubset(array('level3' => null, 'other' => 'otherValue', 'type' => 'defaultLevel2Type'), $configParser->get('level1.level2')); }
/** * @param mixed $config */ public function setConfig($config) { $this->config = $config; $this->config->setDefault($this->getDefaultConfig()); }