public function testWhetherNestedPropertiesAreInserted() { $target = $this->writeConfigToTemporaryFile(''); $config = Config::fromArray(array('a' => array('b' => 'c'))); $writer = new IniWriter($config, $target); $writer->write(); $newConfig = Config::fromIni($target); $this->assertInstanceOf('Icinga\\Data\\ConfigObject', $newConfig->getSection('a'), 'IniWriter does not insert nested properties'); $this->assertEquals('c', $newConfig->getSection('a')->get('b'), 'IniWriter does not insert nested properties'); }
/** * @depends testWhetherNestedPropertiesOfExtendingSectionsAreInserted */ public function testWhetherNestedPropertiesOfExtendingSectionsAreDeleted() { $this->markTestSkipped('Implementation has changed. There is no "Extend" functionality anymore in our Config object'); $target = $this->writeConfigToTemporaryFile(<<<'EOD' [foo] a.b = "c" [bar : foo] d.e = "f" EOD ); $config = Config::fromArray(array('foo' => array('a' => array('b' => 'c')), 'bar' => array())); $config->setExtend('bar', 'foo'); $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = Config::fromIni($target); $this->assertNull($newConfig->get('bar')->get('d'), 'IniWriter does not delete nested properties of extending sections'); }
public function testExplicitRemove() { $filename = tempnam(sys_get_temp_dir(), 'iw2'); $config = Config::fromArray(array('garbage' => array('foobar' => 'lolcat'))); $iniWriter = new IniWriter($config, $filename); $iniWriter->write(); $section = $config->getSection('garbage'); $section->foobar = null; $iniWriter = new IniWriter($config, $filename); $this->assertNotContains('foobar', $iniWriter->render(), 'IniWriter doesn\'t remove section keys with null values'); unlink($filename); }