Esempio n. 1
0
 /**
  * Work through all Remove commands.
  *
  * @return void
  */
 public function enumerateRemoves()
 {
     foreach ($this->removals as $remove) {
         $key = $remove->getProperty();
         $section = $remove->getSection();
         if ($section == '') {
             $this->log("Remove: section must be set", Project::MSG_ERR);
             continue;
         }
         $this->ini->remove($section, $key);
         if ($section != '' && $key != '') {
             $this->log("{$key} in section [{$section}] has been removed.", Project::MSG_DEBUG);
         } elseif ($section != '' && $key == '') {
             $this->log("[{$section}] has been removed.", Project::MSG_DEBUG);
         }
     }
 }
Esempio n. 2
0
 public function testConfigWithoutSection()
 {
     $config = new IniFileConfig(dirname(__FILE__) . '/real.conf', dirname(__FILE__) . '/default.conf', $useSections = false);
     self::assertEquals(array('a1' => '1', 'a2' => 'overwritten', 'b1' => '3', 'b2' => 'also overwritten'), $config->getArray());
     self::assertEquals('overwritten', $config->get('a2'));
     self::assertEquals('also overwritten', $config->get('b2', 'section_b'));
     try {
         $config->setDefaultSection('section_b');
         self::fail('Setting a default section when not using sections should throw exception.');
     } catch (ConfigException $e) {
     }
     try {
         $config->get('wrong_variable');
         self::fail('Should have thrown an exception.');
     } catch (ConfigException $e) {
     }
 }