public function test_save_shouldActuallyStoreValues()
 {
     $this->settings->getSetting('test2')->setValue('value2');
     $this->settings->getSetting('test3')->setValue('value3');
     $this->assertStoredSettingsValue(null, 'test2');
     $this->assertStoredSettingsValue(null, 'test3');
     $this->settings->save();
     $this->assertStoredSettingsValue('value2', 'test2');
     $this->assertStoredSettingsValue('value3', 'test3');
 }
Ejemplo n.º 2
0
 public function getSettingValue($name)
 {
     $settings = new MeasurableSettings($this->id, $this->getType());
     $setting = $settings->getSetting($name);
     if (!empty($setting)) {
         return $setting->getValue();
         // Calling `getValue` makes sure we respect read permission of this setting
     }
     throw new Exception(sprintf('Setting %s does not exist', $name));
 }
Ejemplo n.º 3
0
 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);
 }