Пример #1
0
 static function removeEntry($file, $has_sections, $key)
 {
     $properties = PropertiesUtils::readFromFile($file, $has_sections);
     unset($properties[$key]);
     PropertiesUtils::saveToFile($file, $properties, $has_sections);
 }
Пример #2
0
 function testRemoveEntry()
 {
     $file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/properties_dir/test_folder_2/remove_props.ini");
     $properties = array("entry1" => array("one" => 1, "two" => 2, "mondo" => "mah"), "entry2" => array("one" => 7, "two" => 16, "mondo" => "blah"), 3 => array("pizza" => 5, "problems" => 0));
     PropertiesUtils::saveToFile($file, $properties, true);
     PropertiesUtils::removeEntry($file, true, "entry2");
     $removed = PropertiesUtils::readFromFile($file, true);
     $this->assertTrue(count($removed) == 2, "Il numero delle proprietà non corrisponde!!");
     $this->assertTrue(isset($removed["entry1"]), "entry1 è stata cancellata!!");
     $this->assertFalse(isset($removed["entry2"]), "entry2 non è stata cancellata!!");
     $this->assertTrue(isset($removed[3]), "'3' è stata cancellata!!");
     $this->assertEqual($removed["entry1"]["one"], 1, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed["entry1"]["two"], 2, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed["entry1"]["mondo"], "mah", "Il valore della properties non corrisponde!");
     $this->assertTrue(count($removed["entry1"]) == 3, "Il numero delle chiavi non corrisponde!");
     $this->assertEqual($removed[3]["pizza"], 5, "Il valore della properties non corrisponde!");
     $this->assertEqual($removed[3]["problems"], 0, "Il valore della properties non corrisponde!");
     $this->assertTrue(count($removed[3]) == 2, "Il numero delle chiavi non corrisponde!");
 }
Пример #3
0
 function saveAll($props)
 {
     $this->create();
     PropertiesUtils::saveToFile($this->storage_file, $props, true);
 }