public function testGetSettingValue_shouldReturnValue_IfSettingExistsAndIsReadable() { $setting = new MeasurableSettings($this->idSite, Measurable::getTypeFor($this->idSite)); $setting->getSetting($this->settingName)->setValue('mytest'); $value = $this->measurable->getSettingValue($this->settingName); $this->assertNull($value); $setting->save(); // actually save value $value = $this->measurable->getSettingValue($this->settingName); $this->assertSame('mytest', $value); }
private function updateMeasurableSettings($idSite, $settings) { $idType = Site::getTypeFor($idSite); $measurableSettings = new MeasurableSettings($idSite, $idType); foreach ($measurableSettings->getSettingsForCurrentUser() as $measurableSetting) { $name = $measurableSetting->getName(); if (!empty($settings[$name])) { $measurableSetting->setValue($settings[$name]); } // we do not clear existing settings if the value is missing. // There can be so many settings added by random plugins one would always clear some settings. } $measurableSettings->save(); }
/** * @expectedException \Exception * @expectedExceptionMessage checkUserHasAdminAccess */ public function test_save_shouldCheckAdminPermissionsForThatSite() { FakeAccess::clearAccess(); $this->settings->save(); }