Merge branch 'master' into feature/setup-wizard-7163

Conflicts:
	library/Icinga/Authentication/Backend/LdapUserBackend.php
	library/Icinga/File/Ini/IniWriter.php
This commit is contained in:
Johannes Meyer 2014-11-04 14:22:53 +01:00
commit 170ded6510
42 changed files with 178 additions and 156 deletions

View File

@ -9,7 +9,7 @@ use Icinga\Web\Controller\ActionController;
use Icinga\Form\Authentication\LoginForm;
use Icinga\Authentication\AuthChain;
use Icinga\Application\Config;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Exception\AuthenticationException;
use Icinga\Exception\NotReadableError;
use Icinga\Exception\ConfigurationError;

View File

@ -2,16 +2,16 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Url;
use Icinga\Logger\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\Application\Config;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
use Icinga\Web\Controller\ActionController;
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
@ -36,7 +36,7 @@ class DashboardController extends ActionController
{
$dashboard = new Dashboard();
try {
$dashboardConfig = IcingaConfig::app($config);
$dashboardConfig = Config::app($config);
if (count($dashboardConfig) === 0) {
return null;
}
@ -92,7 +92,7 @@ class DashboardController extends ActionController
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)) {
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
} else {
@ -125,7 +125,7 @@ class DashboardController extends ActionController
$dashboard->activate($pane);
}
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
$this->view->configPath = Config::resolvePath(self::DEFAULT_CONFIG);
if ($dashboard === null) {
$this->view->title = 'Dashboard';
@ -158,7 +158,7 @@ class DashboardController extends ActionController
*/
protected function writeConfiguration(Zend_Config $config, $target)
{
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
try {
$writer->write();

View File

@ -4,7 +4,7 @@
// namespace Icinga\Application\Controllers;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;

View File

@ -4,7 +4,7 @@
use Icinga\Web\Controller\ActionController;
use Icinga\Filter\Filter;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
/**
* Application wide interface for filtering

View File

@ -5,9 +5,7 @@
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Hook;
use Icinga\Web\Url;
use Icinga\Data\ResourceFactory;
use Icinga\Logger\Logger;
use Icinga\Logger\Writer\FileWriter;
use Icinga\Application\Logger;
use Icinga\Protocol\File\FileReader;
use \Zend_Controller_Action_Exception as ActionError;

View File

@ -4,7 +4,7 @@
use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Web\FileCache;
use Zend_Controller_Action_Exception as ActionException;

View File

@ -5,7 +5,7 @@
namespace Icinga\Form\Config\General;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Web\Form;
use Icinga\Web\Form\Validator\WritablePathValidator;

View File

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

View File

@ -6,7 +6,7 @@ namespace Icinga\Form;
use Exception;
use DateTimeZone;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\User\Preferences;
use Icinga\User\Preferences\PreferencesStore;
use Icinga\Util\TimezoneDetect;

View File

@ -11,7 +11,7 @@ use Icinga\Application\Modules\Manager as ModuleManager;
use Icinga\Data\ResourceFactory;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Util\DateTimeFactory;
use Icinga\Util\Translator;
use Icinga\Exception\IcingaException;
@ -397,6 +397,7 @@ abstract class ApplicationBootstrap
return false; // Continue with the normal error handler
}
switch($errno) {
case E_WARNING:
case E_STRICT:
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

View File

@ -9,7 +9,7 @@ use Icinga\Application\ApplicationBootstrap;
use Icinga\Cli\Params;
use Icinga\Cli\Loader;
use Icinga\Cli\Screen;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Application\Benchmark;
use Icinga\Exception\ProgrammingError;
use Zend_Config;

View File

@ -2,13 +2,13 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Logger;
namespace Icinga\Application;
use Exception;
use Zend_Config;
use Icinga\Application\Logger\Writer\FileWriter;
use Icinga\Application\Logger\Writer\SyslogWriter;
use Icinga\Exception\ConfigurationError;
use Icinga\Logger\Writer\FileWriter;
use Icinga\Logger\Writer\SyslogWriter;
/**
* Logger
@ -57,7 +57,7 @@ class Logger
/**
* Log writer
*
* @var \Icinga\Logger\LogWriter
* @var \Icinga\Application\Logger\LogWriter
*/
protected $writer;
@ -133,12 +133,12 @@ class Logger
*
* @param Zend_Config $config The configuration to initialize the writer with
*
* @return \Icinga\Logger\LogWriter The requested log writer
* @throws ConfigurationError If the requested writer cannot be found
* @return \Icinga\Application\Logger\LogWriter The requested log writer
* @throws ConfigurationError If the requested writer cannot be found
*/
protected function createWriter(Zend_Config $config)
{
$class = 'Icinga\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer';
$class = 'Icinga\\Application\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer';
if (! class_exists($class)) {
throw new ConfigurationError(
'Cannot find log writer of type "%s"',
@ -258,7 +258,7 @@ class Logger
/**
* Get the log writer to use
*
* @return \Icinga\Logger\LogWriter
* @return \Icinga\Application\Logger\LogWriter
*/
public function getWriter()
{

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Logger;
namespace Icinga\Application\Logger;
use Zend_Config;

View File

@ -2,13 +2,13 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Logger\Writer;
namespace Icinga\Application\Logger\Writer;
use Exception;
use Zend_Config;
use Icinga\Application\Logger;
use Icinga\Application\Logger\LogWriter;
use Icinga\Exception\ConfigurationError;
use Icinga\Logger\Logger;
use Icinga\Logger\LogWriter;
use Icinga\Util\File;
/**

View File

@ -2,11 +2,11 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Logger\Writer;
namespace Icinga\Application\Logger\Writer;
use Zend_Config;
use Icinga\Logger\Logger;
use Icinga\Logger\LogWriter;
use Icinga\Application\Logger;
use Icinga\Application\Logger\LogWriter;
/**
* Log to the syslog service

View File

@ -6,7 +6,7 @@ namespace Icinga\Application\Modules;
use Icinga\Application\ApplicationBootstrap;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Data\SimpleQuery;
use Icinga\Exception\ConfigurationError;

View File

@ -12,7 +12,7 @@ use Zend_Controller_Router_Route_Regex as RegexRoute;
use Icinga\Application\ApplicationBootstrap;
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Util\Translator;
use Icinga\Web\Hook;
use Icinga\Web\Menu;

View File

@ -9,7 +9,7 @@ require_once __DIR__ . '/ApplicationBootstrap.php';
use Icinga\Authentication\Manager as AuthenticationManager;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Util\TimezoneDetect;
use Icinga\Web\Request;
use Icinga\Web\Response;

View File

@ -6,7 +6,7 @@ namespace Icinga\Authentication;
use Iterator;
use Zend_Config;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
/**

View File

@ -78,8 +78,16 @@ class LdapUserBackend extends UserBackend
*/
public function assertAuthenticationPossible()
{
$q = $this->conn->select()->setBase($this->baseDn)->from($this->userClass);
$result = $q->fetchRow();
try {
$q = $this->conn->select()->setBase($this->baseDn)->from($this->userClass);
$result = $q->fetchRow();
} catch (LdapException $e) {
throw new AuthenticationException(
'Connection not possible: %s',
$e->getMessage()
);
}
if (! isset($result)) {
throw new AuthenticationException(
'No objects with objectClass="%s" in DN="%s" found.',
@ -168,7 +176,7 @@ class LdapUserBackend extends UserBackend
} catch (AuthenticationException $e) {
// Authentication not possible
throw new AuthenticationException(
'Authentication against backend "%s" not possible: ',
'Authentication against backend "%s" not possible: %s',
$this->getName(),
$e
);

View File

@ -9,7 +9,7 @@ use Zend_Config;
use Icinga\Application\Config;
use Icinga\Exception\IcingaException;
use Icinga\Exception\NotReadableError;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\User;
use Icinga\User\Preferences;
use Icinga\User\Preferences\PreferencesStore;

View File

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

View File

@ -2,18 +2,17 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Config;
namespace Icinga\File\Ini;
use Zend_Config;
use Zend_Config_Ini;
use Zend_Config_Exception;
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
@ -30,7 +29,7 @@ class PreservingIniWriter extends Zend_Config_Writer_FileAbstract
public static $fileMode;
/**
* Create a new PreservingIniWriter
* Create a new INI writer
*
* @param array $options Supports all options of Zend_Config_Writer and additional options:
* * filemode: The mode to set on new files

View File

@ -7,7 +7,7 @@ namespace Icinga\Protocol\Ldap;
use Icinga\Protocol\Ldap\Exception as LdapException;
use Icinga\Application\Platform;
use Icinga\Application\Config;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Zend_Config;
/**

View File

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

View File

@ -5,7 +5,7 @@
namespace Icinga\Web;
use Exception;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Exception\ProgrammingError;
/**

View File

@ -9,7 +9,7 @@ use RecursiveIterator;
use Zend_Config;
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Url;

View File

@ -6,7 +6,7 @@ namespace Icinga\Web;
use Exception;
use RecursiveIteratorIterator;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
/**
* A renderer to draw a menu with its sub-menus using an unordered html list

View File

@ -6,7 +6,7 @@ namespace Icinga\Web;
use Icinga\Exception\ProgrammingError;
use Icinga\Application\Platform;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Web\Session;
/**

View File

@ -4,7 +4,7 @@
namespace Icinga\Web\Session;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
/**

View File

@ -7,7 +7,7 @@ namespace Icinga\Web\Widget\Chart;
use Icinga\Web\Widget\AbstractWidget;
use Icinga\Web\Url;
use Icinga\Util\Format;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
/**
* A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the

View File

@ -4,7 +4,7 @@
use Icinga\Application\Icinga;
use Icinga\Application\Config;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Module\Monitoring\Form\Command\DisableNotificationWithExpireForm;
use Icinga\Module\Monitoring\Form\Command\SingleArgumentCommandForm;
use Icinga\Web\Form;

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Zend_Db_Select;
class GroupSummaryQuery extends IdoQuery

View File

@ -5,7 +5,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use Icinga\Exception\IcingaException;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Data\Db\DbQuery;
use Icinga\Exception\ProgrammingError;
use Icinga\Application\Icinga;

View File

@ -6,7 +6,7 @@ namespace Icinga\Module\Monitoring\Command\Transport;
use Exception;
use LogicException;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Module\Monitoring\Command\Exception\TransportException;
use Icinga\Module\Monitoring\Command\IcingaCommand;
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;

View File

@ -5,7 +5,7 @@
namespace Icinga\Module\Monitoring\Command\Transport;
use LogicException;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Module\Monitoring\Command\Exception\TransportException;
use Icinga\Module\Monitoring\Command\IcingaCommand;
use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer;

View File

@ -130,7 +130,8 @@ class Host extends MonitoredObject
'host_notes_url',
'host_modified_host_attributes',
'host_problem',
'host_process_performance_data'
'host_process_performance_data',
'process_perfdata' => 'host_process_performance_data'
))
->where('host_name', $this->host);
}

View File

@ -317,10 +317,12 @@ abstract class MonitoredObject
'contact_alias',
'contact_email',
'contact_pager',
))
->where('host_name', $this->host_name);
));
if ($this->type === self::TYPE_SERVICE) {
$contacts->where('service_host_name', $this->host_name);
$contacts->where('service_description', $this->service_description);
} else {
$contacts->where('host_name', $this->host_name);
}
$this->contacts = $contacts->getQuery()->fetchAll();
return $this;

View File

@ -191,6 +191,7 @@ class Service extends MonitoredObject
'service_flap_detection_enabled_changed',
'service_modified_service_attributes',
'service_process_performance_data',
'process_perfdata' => 'service_process_performance_data',
'service_percent_state_change',
'service_host_name'
))

View File

@ -269,15 +269,24 @@
}
} else {
if (req.$target.attr('id') === 'col2') { // TODO: multicol
if ($('#col1').data('icingaUrl') === redirect) {
icinga.ui.layout1col();
req.$target = $('#col1');
delete(this.requests['col2']);
}
}
this.loadUrl(redirect, req.$target);
if (redirect.match(/#!/)) {
var parts = redirect.split(/#!/);
icinga.ui.layout2col();
this.loadUrl(parts.shift(), $('#col1'));
this.loadUrl(parts.shift(), $('#col2'));
} else {
if (req.$target.attr('id') === 'col2') { // TODO: multicol
if ($('#col1').data('icingaUrl') === redirect) {
icinga.ui.layout1col();
req.$target = $('#col1');
delete(this.requests['col2']);
}
}
this.loadUrl(redirect, req.$target);
}
}
return true;
},
@ -672,6 +681,8 @@
}
}
$container.trigger('beforerender');
var discard = false;
$.each(self.icinga.behaviors, function(name, behavior) {
if (behavior.renderHook) {
@ -691,11 +702,12 @@
var $content = $('<div>' + content + '</div>');
// Disable all click events while rendering
$('*').click(function (event) {
event.stopImmediatePropagation();
event.stopPropagation();
event.preventDefault();
});
// (Disabling disabled, was ways too slow)
// $('*').click(function (event) {
// event.stopImmediatePropagation();
// event.stopPropagation();
// event.preventDefault();
// });
$('.container', $container).each(function() {
self.stopPendingRequestsFor($(this));
@ -738,8 +750,8 @@
icinga.ui.initializeControls($container);
icinga.ui.fixControls();
// Re-enable all click events
$('*').off('click');
// Re-enable all click events (disabled as of performance reasons)
// $('*').off('click');
},
/**

View File

@ -6,10 +6,10 @@ namespace Tests\Icinga\Config;
use Zend_Config;
use Zend_Config_Ini;
use Icinga\File\Ini\IniWriter;
use Icinga\Test\BaseTestCase;
use Icinga\Config\PreservingIniWriter;
class PreservingIniWriterTest extends BaseTestCase
class IniWriterTest extends BaseTestCase
{
protected $tempFile;
protected $tempFile2;
@ -34,22 +34,22 @@ class PreservingIniWriterTest extends BaseTestCase
{
$target = $this->writeConfigToTemporaryFile('');
$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();
$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()
{
$target = $this->writeConfigToTemporaryFile('key1 = "1"');
$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();
$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"');
$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();
$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"');
$config = new Zend_Config(array());
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$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()
{
$target = $this->writeConfigToTemporaryFile('');
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('a'),
'PreservingIniWriter does not insert nested properties'
'IniWriter does not insert nested properties'
);
$this->assertEquals(
'c',
$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"');
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('a'),
'PreservingIniWriter does not update nested properties'
'IniWriter does not update nested properties'
);
$this->assertEquals(
'cc',
$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"');
$config = new Zend_Config(array());
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertNull(
$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('');
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('section'),
'PreservingIniWriter does not insert sections'
'IniWriter does not insert sections'
);
$this->assertEquals(
'value',
$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
);
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertEquals(
'eulav',
$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
);
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertNull(
$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('');
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('section'),
'PreservingIniWriter does not insert sections'
'IniWriter does not insert sections'
);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('section')->get('a'),
'PreservingIniWriter does not insert nested section properties'
'IniWriter does not insert nested section properties'
);
$this->assertEquals(
'c',
$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
);
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertEquals(
'cc',
$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
);
$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();
$newConfig = new Zend_Config_Ini($target);
$this->assertNull(
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('foo'),
'PreservingIniWriter does not insert extended sections'
'IniWriter does not insert extended sections'
);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('bar'),
'PreservingIniWriter does not insert extending sections'
'IniWriter does not insert extending sections'
);
$this->assertEquals(
'2',
$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(
'1',
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertEquals(
'22',
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertNull(
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('foo'),
'PreservingIniWriter does not insert extended sections'
'IniWriter does not insert extended sections'
);
$this->assertInstanceOf(
'\Zend_Config',
$newConfig->get('bar'),
'PreservingIniWriter does not insert extending sections'
'IniWriter does not insert extending sections'
);
$this->assertInstanceOf(
'\Zend_Config',
$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(
'f',
$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(
'c',
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertEquals(
'ff',
$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');
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = new Zend_Config_Ini($target);
$this->assertNull(
$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"
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array(
'config' => new Zend_Config(
array(
@ -535,7 +535,7 @@ EOD;
$this->assertEquals(
trim($reverted),
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]
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array(
'config' => new Zend_Config(
array(
@ -574,7 +574,7 @@ EOD;
$this->assertEquals(
trim($reverted),
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
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target)
);
$this->assertEquals(
$config,
$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...
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array(
'config' => new Zend_Config(
array(
@ -625,7 +625,7 @@ EOD;
$this->assertEquals(
$config,
$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"
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target)
);
$this->assertEquals(
$config,
$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...
EOD;
$target = $this->writeConfigToTemporaryFile($config);
$writer = new PreservingIniWriter(
$writer = new IniWriter(
array(
'config' => new Zend_Config(
array(
@ -677,13 +677,13 @@ EOD;
$this->assertEquals(
$config,
$writer->render(),
'PreservingIniWriter does not preserve comments on property lines'
'IniWriter does not preserve comments on property lines'
);
}
public function testKeyNormalization()
{
$normalKeys = new PreservingIniWriter(
$normalKeys = new IniWriter(
array (
'config' => new Zend_Config(array (
'foo' => 'bar',
@ -704,7 +704,7 @@ EOD;
);
$nestedKeys = new PreservingIniWriter(
$nestedKeys = new IniWriter(
array (
'config' => new Zend_Config(array (
'foo' => 'bar',

View File

@ -5,9 +5,9 @@
namespace Tests\Icinga\Logger\Writer;
use Zend_Config;
use Icinga\Logger\Logger;
use Icinga\Application\Logger;
use Icinga\Application\Logger\Writer\FileWriter;
use Icinga\Test\BaseTestCase;
use Icinga\Logger\Writer\FileWriter;
class StreamWriterTest extends BaseTestCase
{