public function testUpdatesConfigFileWithSettings() { $setting1 = ConfigSetting::ParseForm('key1|', 'true'); $setting2 = ConfigSetting::ParseForm('key2|section1', '10'); $setting3 = ConfigSetting::ParseForm('key3|section1', 'some string'); $expectedSettings['key1'] = 'true'; $expectedSettings['section1']['key2'] = '10'; $expectedSettings['section1']['key3'] = 'some string'; $existingValues['oldKey1'] = 'old1'; $existingValues['section2']['oldKey2'] = 'old2'; $newSettings['key1'] = 'true'; $newSettings['section1']['key2'] = '10'; $newSettings['section1']['key3'] = 'some string'; $newSettings['oldKey1'] = 'old1'; $newSettings['section2']['oldKey2'] = 'old2'; $this->page->_SubmittedSettings = array($setting1, $setting2, $setting3); $this->configSettings->expects($this->once())->method('GetSettings')->with($this->equalTo($this->configFilePath))->will($this->returnValue($existingValues)); $this->configSettings->expects($this->once())->method('WriteSettings')->with($this->equalTo($this->configFilePath), $this->equalTo($newSettings)); $this->presenter->Update(); }
/** * @return array|ConfigSetting[] */ public function GetSubmittedSettings() { $settingNames = $this->GetRawForm('setting_names'); $settings = explode(',', $settingNames); $submittedSettings = array(); foreach ($settings as $setting) { $setting = trim($setting); if (!empty($setting)) { // Log::Debug("%s=%s", $setting, $this->GetForm($setting)); $submittedSettings[] = ConfigSetting::ParseForm($setting, stripslashes($this->GetRawForm($setting))); } } return $submittedSettings; }