Move INI writer classes to the File namespace

fixes #7150
This commit is contained in:
Eric Lippmann 2014-10-31 10:54:53 +01:00
parent 16352fc10c
commit b38e3affb9
6 changed files with 88 additions and 89 deletions

View File

@ -2,16 +2,16 @@
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Url; use Icinga\Application\Config;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Config\PreservingIniWriter;
use Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Widget\Dashboard;
use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Exception\NotReadableError;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Web\Controller\ActionController;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\NotReadableError;
use Icinga\File\Ini\IniWriter;
use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Web\Controller\ActionController;
use Icinga\Web\Url;
use Icinga\Web\Widget\Dashboard;
/** /**
* Handle creation, removal and displaying of dashboards, panes and components * Handle creation, removal and displaying of dashboards, panes and components
@ -36,7 +36,7 @@ class DashboardController extends ActionController
{ {
$dashboard = new Dashboard(); $dashboard = new Dashboard();
try { try {
$dashboardConfig = IcingaConfig::app($config); $dashboardConfig = Config::app($config);
if (count($dashboardConfig) === 0) { if (count($dashboardConfig) === 0) {
return null; return null;
} }
@ -92,7 +92,7 @@ class DashboardController extends ActionController
ltrim($form->getValue('url'), '/') ltrim($form->getValue('url'), '/')
); );
$configFile = IcingaConfig::app('dashboard/dashboard')->getConfigFile(); $configFile = Config::app('dashboard/dashboard')->getConfigFile();
if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) { if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) {
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane')))); $this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
} else { } else {
@ -125,7 +125,7 @@ class DashboardController extends ActionController
$dashboard->activate($pane); $dashboard->activate($pane);
} }
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG); $this->view->configPath = Config::resolvePath(self::DEFAULT_CONFIG);
if ($dashboard === null) { if ($dashboard === null) {
$this->view->title = 'Dashboard'; $this->view->title = 'Dashboard';
@ -158,7 +158,7 @@ class DashboardController extends ActionController
*/ */
protected function writeConfiguration(Zend_Config $config, $target) protected function writeConfiguration(Zend_Config $config, $target)
{ {
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
try { try {
$writer->write(); $writer->write();

View File

@ -7,7 +7,7 @@ namespace Icinga\Form;
use Exception; use Exception;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Config\PreservingIniWriter; use Icinga\File\Ini\IniWriter;
/** /**
* Form base-class providing standard functionality for configuration forms * Form base-class providing standard functionality for configuration forms
@ -43,7 +43,7 @@ class ConfigForm extends Form
*/ */
public function save() public function save()
{ {
$writer = new PreservingIniWriter( $writer = new IniWriter(
array( array(
'config' => $this->config, 'config' => $this->config,
'filename' => $this->config->getConfigFile() 'filename' => $this->config->getConfigFile()

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Config; namespace Icinga\File\Ini;
/** /**
* Edit the sections and keys of an ini in-place * Edit the sections and keys of an ini in-place

View File

@ -2,17 +2,16 @@
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Config; namespace Icinga\File\Ini;
use Zend_Config; use Zend_Config;
use Zend_Config_Ini; use Zend_Config_Ini;
use Zend_Config_Writer_FileAbstract; use Zend_Config_Writer_FileAbstract;
use Icinga\Config\IniEditor;
/** /**
* A ini file adapter that respects the file structure and the comments of already existing ini files * A INI file adapter that respects the file structure and the comments of already existing ini files
*/ */
class PreservingIniWriter extends Zend_Config_Writer_FileAbstract class IniWriter extends Zend_Config_Writer_FileAbstract
{ {
/** /**
* Stores the options * Stores the options
@ -22,7 +21,7 @@ class PreservingIniWriter extends Zend_Config_Writer_FileAbstract
protected $options; protected $options;
/** /**
* Create a new PreservingIniWriter * Create a new INI writer
* *
* @param array $options Supports all options of Zend_Config_Writer and additional * @param array $options Supports all options of Zend_Config_Writer and additional
* options for the internal IniEditor: * options for the internal IniEditor:

View File

@ -5,12 +5,12 @@
namespace Icinga\User\Preferences\Store; namespace Icinga\User\Preferences\Store;
use Zend_Config; use Zend_Config;
use Icinga\Util\File;
use Icinga\Config\PreservingIniWriter;
use Icinga\Exception\NotReadableError; use Icinga\Exception\NotReadableError;
use Icinga\Exception\NotWritableError; use Icinga\Exception\NotWritableError;
use Icinga\File\Ini\IniWriter;
use Icinga\User\Preferences; use Icinga\User\Preferences;
use Icinga\User\Preferences\PreferencesStore; use Icinga\User\Preferences\PreferencesStore;
use Icinga\Util\File;
/** /**
* Load and save user preferences from and to INI files * Load and save user preferences from and to INI files
@ -34,7 +34,7 @@ class IniStore extends PreferencesStore
/** /**
* Writer which stores the preferences * Writer which stores the preferences
* *
* @var PreservingIniWriter * @var IniWriter
*/ */
protected $writer; protected $writer;
@ -114,7 +114,7 @@ class IniStore extends PreferencesStore
); );
} }
$this->writer = new PreservingIniWriter( $this->writer = new IniWriter(
array( array(
'config' => new Zend_Config($this->preferences), 'config' => new Zend_Config($this->preferences),
'filename' => $this->preferencesFile 'filename' => $this->preferencesFile

View File

@ -6,10 +6,10 @@ namespace Tests\Icinga\Config;
use Zend_Config; use Zend_Config;
use Zend_Config_Ini; use Zend_Config_Ini;
use Icinga\File\Ini\IniWriter;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Icinga\Config\PreservingIniWriter;
class PreservingIniWriterTest extends BaseTestCase class IniWriterTest extends BaseTestCase
{ {
protected $tempFile; protected $tempFile;
protected $tempFile2; protected $tempFile2;
@ -34,22 +34,22 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile(''); $target = $this->writeConfigToTemporaryFile('');
$config = new Zend_Config(array('key' => 'value')); $config = new Zend_Config(array('key' => 'value'));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals('value', $newConfig->get('key'), 'PreservingIniWriter does not insert in empty files'); $this->assertEquals('value', $newConfig->get('key'), 'IniWriter does not insert in empty files');
} }
public function testWhetherSimplePropertiesAreInsertedInExistingFiles() public function testWhetherSimplePropertiesAreInsertedInExistingFiles()
{ {
$target = $this->writeConfigToTemporaryFile('key1 = "1"'); $target = $this->writeConfigToTemporaryFile('key1 = "1"');
$config = new Zend_Config(array('key2' => '2')); $config = new Zend_Config(array('key2' => '2'));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals('2', $newConfig->get('key2'), 'PreservingIniWriter does not insert in existing files'); $this->assertEquals('2', $newConfig->get('key2'), 'IniWriter does not insert in existing files');
} }
/** /**
@ -59,11 +59,11 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile('key = "value"'); $target = $this->writeConfigToTemporaryFile('key = "value"');
$config = new Zend_Config(array('key' => 'eulav')); $config = new Zend_Config(array('key' => 'eulav'));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals('eulav', $newConfig->get('key'), 'PreservingIniWriter does not update simple properties'); $this->assertEquals('eulav', $newConfig->get('key'), 'IniWriter does not update simple properties');
} }
/** /**
@ -73,30 +73,30 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile('key = "value"'); $target = $this->writeConfigToTemporaryFile('key = "value"');
$config = new Zend_Config(array()); $config = new Zend_Config(array());
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull($newConfig->get('key'), 'PreservingIniWriter does not delete simple properties'); $this->assertNull($newConfig->get('key'), 'IniWriter does not delete simple properties');
} }
public function testWhetherNestedPropertiesAreInserted() public function testWhetherNestedPropertiesAreInserted()
{ {
$target = $this->writeConfigToTemporaryFile(''); $target = $this->writeConfigToTemporaryFile('');
$config = new Zend_Config(array('a' => array('b' => 'c'))); $config = new Zend_Config(array('a' => array('b' => 'c')));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('a'), $newConfig->get('a'),
'PreservingIniWriter does not insert nested properties' 'IniWriter does not insert nested properties'
); );
$this->assertEquals( $this->assertEquals(
'c', 'c',
$newConfig->get('a')->get('b'), $newConfig->get('a')->get('b'),
'PreservingIniWriter does not insert nested properties' 'IniWriter does not insert nested properties'
); );
} }
@ -107,19 +107,19 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile('a.b = "c"'); $target = $this->writeConfigToTemporaryFile('a.b = "c"');
$config = new Zend_Config(array('a' => array('b' => 'cc'))); $config = new Zend_Config(array('a' => array('b' => 'cc')));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('a'), $newConfig->get('a'),
'PreservingIniWriter does not update nested properties' 'IniWriter does not update nested properties'
); );
$this->assertEquals( $this->assertEquals(
'cc', 'cc',
$newConfig->get('a')->get('b'), $newConfig->get('a')->get('b'),
'PreservingIniWriter does not update nested properties' 'IniWriter does not update nested properties'
); );
} }
@ -130,13 +130,13 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile('a.b = "c"'); $target = $this->writeConfigToTemporaryFile('a.b = "c"');
$config = new Zend_Config(array()); $config = new Zend_Config(array());
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull( $this->assertNull(
$newConfig->get('a'), $newConfig->get('a'),
'PreservingIniWriter does not delete nested properties' 'IniWriter does not delete nested properties'
); );
} }
@ -144,19 +144,19 @@ class PreservingIniWriterTest extends BaseTestCase
{ {
$target = $this->writeConfigToTemporaryFile(''); $target = $this->writeConfigToTemporaryFile('');
$config = new Zend_Config(array('section' => array('key' => 'value'))); $config = new Zend_Config(array('section' => array('key' => 'value')));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('section'), $newConfig->get('section'),
'PreservingIniWriter does not insert sections' 'IniWriter does not insert sections'
); );
$this->assertEquals( $this->assertEquals(
'value', 'value',
$newConfig->get('section')->get('key'), $newConfig->get('section')->get('key'),
'PreservingIniWriter does not insert simple section properties' 'IniWriter does not insert simple section properties'
); );
} }
@ -171,14 +171,14 @@ key = "value"
EOD EOD
); );
$config = new Zend_Config(array('section' => array('key' => 'eulav'))); $config = new Zend_Config(array('section' => array('key' => 'eulav')));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals( $this->assertEquals(
'eulav', 'eulav',
$newConfig->get('section')->get('key'), $newConfig->get('section')->get('key'),
'PreservingIniWriter does not update simple section properties' 'IniWriter does not update simple section properties'
); );
} }
@ -193,13 +193,13 @@ key = "value"
EOD EOD
); );
$config = new Zend_Config(array('section' => array())); $config = new Zend_Config(array('section' => array()));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull( $this->assertNull(
$newConfig->get('section')->get('key'), $newConfig->get('section')->get('key'),
'PreservingIniWriter does not delete simple section properties' 'IniWriter does not delete simple section properties'
); );
} }
@ -207,24 +207,24 @@ EOD
{ {
$target = $this->writeConfigToTemporaryFile(''); $target = $this->writeConfigToTemporaryFile('');
$config = new Zend_Config(array('section' => array('a' => array('b' => 'c')))); $config = new Zend_Config(array('section' => array('a' => array('b' => 'c'))));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('section'), $newConfig->get('section'),
'PreservingIniWriter does not insert sections' 'IniWriter does not insert sections'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('section')->get('a'), $newConfig->get('section')->get('a'),
'PreservingIniWriter does not insert nested section properties' 'IniWriter does not insert nested section properties'
); );
$this->assertEquals( $this->assertEquals(
'c', 'c',
$newConfig->get('section')->get('a')->get('b'), $newConfig->get('section')->get('a')->get('b'),
'PreservingIniWriter does not insert nested section properties' 'IniWriter does not insert nested section properties'
); );
} }
@ -239,14 +239,14 @@ a.b = "c"
EOD EOD
); );
$config = new Zend_Config(array('section' => array('a' => array('b' => 'cc')))); $config = new Zend_Config(array('section' => array('a' => array('b' => 'cc'))));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals( $this->assertEquals(
'cc', 'cc',
$newConfig->get('section')->get('a')->get('b'), $newConfig->get('section')->get('a')->get('b'),
'PreservingIniWriter does not update nested section properties' 'IniWriter does not update nested section properties'
); );
} }
@ -261,13 +261,13 @@ a.b = "c"
EOD EOD
); );
$config = new Zend_Config(array('section' => array())); $config = new Zend_Config(array('section' => array()));
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull( $this->assertNull(
$newConfig->get('section')->get('a'), $newConfig->get('section')->get('a'),
'PreservingIniWriter does not delete nested section properties' 'IniWriter does not delete nested section properties'
); );
} }
@ -281,29 +281,29 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('foo'), $newConfig->get('foo'),
'PreservingIniWriter does not insert extended sections' 'IniWriter does not insert extended sections'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('bar'), $newConfig->get('bar'),
'PreservingIniWriter does not insert extending sections' 'IniWriter does not insert extending sections'
); );
$this->assertEquals( $this->assertEquals(
'2', '2',
$newConfig->get('bar')->get('key2'), $newConfig->get('bar')->get('key2'),
'PreservingIniWriter does not insert simple properties into extending sections' 'IniWriter does not insert simple properties into extending sections'
); );
$this->assertEquals( $this->assertEquals(
'1', '1',
$newConfig->get('foo')->get('key1'), $newConfig->get('foo')->get('key1'),
'PreservingIniWriter does not properly define extending sections' 'IniWriter does not properly define extending sections'
); );
} }
@ -327,14 +327,14 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals( $this->assertEquals(
'22', '22',
$newConfig->get('bar')->get('key2'), $newConfig->get('bar')->get('key2'),
'PreservingIniWriter does not update simple properties of extending sections' 'IniWriter does not update simple properties of extending sections'
); );
} }
@ -358,13 +358,13 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull( $this->assertNull(
$newConfig->get('bar')->get('key2'), $newConfig->get('bar')->get('key2'),
'PreservingIniWriter does not delete simple properties of extending sections' 'IniWriter does not delete simple properties of extending sections'
); );
} }
@ -378,34 +378,34 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('foo'), $newConfig->get('foo'),
'PreservingIniWriter does not insert extended sections' 'IniWriter does not insert extended sections'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('bar'), $newConfig->get('bar'),
'PreservingIniWriter does not insert extending sections' 'IniWriter does not insert extending sections'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'\Zend_Config', '\Zend_Config',
$newConfig->get('bar')->get('d'), $newConfig->get('bar')->get('d'),
'PreservingIniWriter does not insert nested properties into extending sections' 'IniWriter does not insert nested properties into extending sections'
); );
$this->assertEquals( $this->assertEquals(
'f', 'f',
$newConfig->get('bar')->get('d')->get('e'), $newConfig->get('bar')->get('d')->get('e'),
'PreservingIniWriter does not insert nested properties into extending sections' 'IniWriter does not insert nested properties into extending sections'
); );
$this->assertEquals( $this->assertEquals(
'c', 'c',
$newConfig->get('bar')->get('a')->get('b'), $newConfig->get('bar')->get('a')->get('b'),
'PreservingIniWriter does not properly define extending sections with nested properties' 'IniWriter does not properly define extending sections with nested properties'
); );
} }
@ -429,14 +429,14 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertEquals( $this->assertEquals(
'ff', 'ff',
$newConfig->get('bar')->get('d')->get('e'), $newConfig->get('bar')->get('d')->get('e'),
'PreservingIniWriter does not update nested properties of extending sections' 'IniWriter does not update nested properties of extending sections'
); );
} }
@ -460,13 +460,13 @@ EOD
) )
); );
$config->setExtend('bar', 'foo'); $config->setExtend('bar', 'foo');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write(); $writer->write();
$newConfig = new Zend_Config_Ini($target); $newConfig = new Zend_Config_Ini($target);
$this->assertNull( $this->assertNull(
$newConfig->get('bar')->get('d'), $newConfig->get('bar')->get('d'),
'PreservingIniWriter does not delete nested properties of extending sections' 'IniWriter does not delete nested properties of extending sections'
); );
} }
@ -504,7 +504,7 @@ key1 = "1"
key2 = "2" key2 = "2"
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array( array(
'config' => new Zend_Config( 'config' => new Zend_Config(
array( array(
@ -535,7 +535,7 @@ EOD;
$this->assertEquals( $this->assertEquals(
trim($reverted), trim($reverted),
trim($writer->render()), trim($writer->render()),
'PreservingIniWriter does not preserve section and/or property order' 'IniWriter does not preserve section and/or property order'
); );
} }
@ -559,7 +559,7 @@ EOD;
[one] [one]
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array( array(
'config' => new Zend_Config( 'config' => new Zend_Config(
array( array(
@ -574,7 +574,7 @@ EOD;
$this->assertEquals( $this->assertEquals(
trim($reverted), trim($reverted),
trim($writer->render()), trim($writer->render()),
'PreservingIniWriter does not preserve section and/or property order' 'IniWriter does not preserve section and/or property order'
); );
} }
@ -588,14 +588,14 @@ key = "value"
; boring comment ; boring comment
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target) array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target)
); );
$this->assertEquals( $this->assertEquals(
$config, $config,
$writer->render(), $writer->render(),
'PreservingIniWriter does not preserve comments on empty lines' 'IniWriter does not preserve comments on empty lines'
); );
} }
@ -608,7 +608,7 @@ key = "value" ; some comment for a small sized pro
xxl = "very loooooooooooooooooooooong" ; my value is very lo... xxl = "very loooooooooooooooooooooong" ; my value is very lo...
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array( array(
'config' => new Zend_Config( 'config' => new Zend_Config(
array( array(
@ -625,7 +625,7 @@ EOD;
$this->assertEquals( $this->assertEquals(
$config, $config,
$writer->render(), $writer->render(),
'PreservingIniWriter does not preserve comments on property lines' 'IniWriter does not preserve comments on property lines'
); );
} }
@ -637,14 +637,14 @@ EOD;
key = "value" key = "value"
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target) array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target)
); );
$this->assertEquals( $this->assertEquals(
$config, $config,
$writer->render(), $writer->render(),
'PreservingIniWriter does not preserve comments on empty section lines' 'IniWriter does not preserve comments on empty section lines'
); );
} }
@ -658,7 +658,7 @@ key = "value" ; some comment for a small sized pro
xxl = "very loooooooooooooooooooooong" ; my value is very lo... xxl = "very loooooooooooooooooooooong" ; my value is very lo...
EOD; EOD;
$target = $this->writeConfigToTemporaryFile($config); $target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter( $writer = new IniWriter(
array( array(
'config' => new Zend_Config( 'config' => new Zend_Config(
array( array(
@ -677,13 +677,13 @@ EOD;
$this->assertEquals( $this->assertEquals(
$config, $config,
$writer->render(), $writer->render(),
'PreservingIniWriter does not preserve comments on property lines' 'IniWriter does not preserve comments on property lines'
); );
} }
public function testKeyNormalization() public function testKeyNormalization()
{ {
$normalKeys = new PreservingIniWriter( $normalKeys = new IniWriter(
array ( array (
'config' => new Zend_Config(array ( 'config' => new Zend_Config(array (
'foo' => 'bar', 'foo' => 'bar',
@ -704,7 +704,7 @@ EOD;
); );
$nestedKeys = new PreservingIniWriter( $nestedKeys = new IniWriter(
array ( array (
'config' => new Zend_Config(array ( 'config' => new Zend_Config(array (
'foo' => 'bar', 'foo' => 'bar',