Merge branch 'bugfix/wrong-namespaces-4543'

fixes #4543
This commit is contained in:
Jannis Moßhammer 2013-08-12 16:12:03 +02:00
commit 55f93389ba
24 changed files with 42 additions and 32 deletions

View File

@ -31,7 +31,7 @@ use Icinga\Web\ActionController;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Dashboard;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Form\Dashboard\AddUrlForm; use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;

View File

@ -28,7 +28,7 @@ namespace Icinga\Web\Form;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Session; use Icinga\Web\Session;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Config\Config; use \Icinga\Application\Config;
/** /**
* Class SettingsForm * Class SettingsForm

View File

@ -2,7 +2,7 @@
namespace Icinga\Form\Dashboard; namespace Icinga\Form\Dashboard;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Dashboard;
use Zend_Form_Element_Text; use Zend_Form_Element_Text;

View File

@ -1,13 +1,13 @@
# Application and Module Configuration # Application and Module Configuration
The \Icinga\Config\Config class is a general purpose service to help you find, load and save The \Icinga\Application\Config class is a general purpose service to help you find, load and save
configuration data. It is used both by the Icinga 2 Web modules and the framework itself. With configuration data. It is used both by the Icinga 2 Web modules and the framework itself. With
INI files as source it enables you to store configuration in a familiar format. Icinga 2 Web INI files as source it enables you to store configuration in a familiar format. Icinga 2 Web
defines some configuration files for its own purposes. Please note that both modules and framework defines some configuration files for its own purposes. Please note that both modules and framework
keep their main configuration in the INI file called config.ini. Here's some example code: keep their main configuration in the INI file called config.ini. Here's some example code:
<?php <?php
use \Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
// Retrieve the default timezone using 'Europe/Berlin' in case it is not set // Retrieve the default timezone using 'Europe/Berlin' in case it is not set
IcingaConfig::app()->global->get('defaultTimezone', 'Europe/Berlin'); IcingaConfig::app()->global->get('defaultTimezone', 'Europe/Berlin');

View File

@ -31,7 +31,7 @@ namespace Icinga\Application;
use Icinga\Application\Modules\Manager as ModuleManager; use Icinga\Application\Modules\Manager as ModuleManager;
use Icinga\Application\Platform; use Icinga\Application\Platform;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Zend_Loader_Autoloader; use Zend_Loader_Autoloader;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;

View File

@ -26,7 +26,7 @@
*/ */
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Config; namespace Icinga\Application;
use Zend_Config_Ini; use Zend_Config_Ini;

View File

@ -29,7 +29,7 @@
namespace Icinga\Application\Modules; namespace Icinga\Application\Modules;
use Icinga\Application\ApplicationBootstrap; use Icinga\Application\ApplicationBootstrap;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Zend_Controller_Router_Route as Route; use Zend_Controller_Router_Route as Route;

View File

@ -32,7 +32,7 @@ use Icinga\User;
use Icinga\Authentication\UserBackend; use Icinga\Authentication\UserBackend;
use Icinga\Authentication\Credentials; use Icinga\Authentication\Credentials;
use Icinga\Protocol\Ldap; use Icinga\Protocol\Ldap;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
/** /**
* User authentication backend (@see Icinga\Authentication\UserBackend) for * User authentication backend (@see Icinga\Authentication\UserBackend) for

View File

@ -29,7 +29,7 @@
namespace Icinga\Authentication; namespace Icinga\Authentication;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Exception\ConfigurationError as ConfigError; use Icinga\Exception\ConfigurationError as ConfigError;
use Icinga\User; use Icinga\User;

View File

@ -2,7 +2,7 @@
namespace Icinga; namespace Icinga;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Authentication\Manager as AuthManager; use Icinga\Authentication\Manager as AuthManager;
class Backend class Backend

View File

@ -6,7 +6,7 @@
namespace Icinga\Protocol\Ldap; namespace Icinga\Protocol\Ldap;
use Icinga\Application\Platform; use Icinga\Application\Platform;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Icinga\Application\Logger as Log; use Icinga\Application\Logger as Log;
/** /**

View File

@ -31,7 +31,7 @@ namespace Icinga\Web;
use Icinga\Authentication\Manager as AuthManager; use Icinga\Authentication\Manager as AuthManager;
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;
use Icinga\Exception; use Icinga\Exception;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Zend_Layout as ZfLayout; use Zend_Layout as ZfLayout;
use Zend_Controller_Action as ZfController; use Zend_Controller_Action as ZfController;

View File

@ -28,7 +28,7 @@
*/ */
namespace Icinga\Web; namespace Icinga\Web;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
/** /**

View File

@ -29,7 +29,7 @@
namespace Icinga\Web\Widget; namespace Icinga\Web\Widget;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Web\Widget\Widget; use Icinga\Web\Widget\Widget;

View File

@ -31,7 +31,7 @@
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Backend; use Icinga\Backend;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Authentication\Manager; use Icinga\Authentication\Manager;
use Icinga\Web\Form; use Icinga\Web\Form;

View File

@ -2,7 +2,7 @@
namespace Monitoring; namespace Monitoring;
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
use Icinga\Authentication\Manager as AuthManager; use Icinga\Authentication\Manager as AuthManager;
use Exception; use Exception;

View File

@ -2,7 +2,7 @@
namespace Monitoring; namespace Monitoring;
use Icinga\Config\Config; use \Icinga\Application\Config;
use Icinga\Web\Session; use Icinga\Web\Session;
use Exception; use Exception;

View File

@ -10,7 +10,7 @@ require 'Zend/Controller/Action.php';
require '../../library/Icinga/Exception/ProgrammingError.php'; require '../../library/Icinga/Exception/ProgrammingError.php';
require '../../library/Icinga/Application/Benchmark.php'; require '../../library/Icinga/Application/Benchmark.php';
require '../../library/Icinga/Config/Config.php'; require '../../library/Icinga/Application/Config.php';
require '../../library/Icinga/Application/Icinga.php'; require '../../library/Icinga/Application/Icinga.php';
require '../../library/Icinga/Web/ActionController.php'; require '../../library/Icinga/Web/ActionController.php';
require '../../library/Icinga/Web/Notification.php'; require '../../library/Icinga/Web/Notification.php';

View File

@ -2,27 +2,37 @@
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Application; namespace Tests\Icinga\Application;
require_once 'Zend/Config/Ini.php'; require_once 'Zend/Config/Ini.php';
require_once '../../library/Icinga/Config/Config.php'; require_once realpath(__DIR__ . '/../../../../../library/Icinga/Application/Config.php');
use Icinga\Config\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
class ConfigTest extends \PHPUnit_Framework_TestCase class ConfigTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Set up config dir
*
* Utilizes singleton IcingaConfig
*
* @backupStaticAttributes enabled
*/
public function setUp() public function setUp()
{ {
IcingaConfig::$configDir = dirname(__FILE__) . '/files'; IcingaConfig::$configDir = dirname(__FILE__) . '/Config/files';
} }
public function testAppConfig() public function testAppConfig()
{ {
$config = IcingaConfig::app(); $config = IcingaConfig::app();
$this->assertEquals(1, $config->logging->enable); $this->assertEquals(1, $config->logging->enable, 'Unexpected value retrieved from config file');
// Test non-existent property where null is the default value // Test non-existent property where null is the default value
$this->assertEquals(null, $config->logging->get('disable')); $this->assertEquals(
null,
$config->logging->get('disable'),
'Unexpected default value for non-existent properties'
);
// Test non-existent property using zero as the default value // Test non-existent property using zero as the default value
$this->assertEquals(0, $config->logging->get('disable', 0)); $this->assertEquals(0, $config->logging->get('disable', 0));
// Test retrieve full section // Test retrieve full section

View File

@ -36,7 +36,7 @@ require_once('Zend/Config/Ini.php');
require_once('Zend/Db.php'); require_once('Zend/Db.php');
require_once('../../library/Icinga/Authentication/UserBackend.php'); require_once('../../library/Icinga/Authentication/UserBackend.php');
require_once('../../library/Icinga/Protocol/Ldap/Exception.php'); require_once('../../library/Icinga/Protocol/Ldap/Exception.php');
require_once('../../library/Icinga/Config/Config.php'); require_once('../../library/Icinga/Application/Config.php');
require_once('../../library/Icinga/Authentication/Credentials.php'); require_once('../../library/Icinga/Authentication/Credentials.php');
require_once('../../library/Icinga/Authentication/Backend/DbUserBackend.php'); require_once('../../library/Icinga/Authentication/Backend/DbUserBackend.php');
require_once('../../library/Icinga/User.php'); require_once('../../library/Icinga/User.php');
@ -45,7 +45,7 @@ use Icinga\Authentication\Backend\DbUserBackend;
use Icinga\Util\Crypto; use Icinga\Util\Crypto;
use Icinga\Authentication\Credentials; use Icinga\Authentication\Credentials;
use Icinga\User; use Icinga\User;
use Icinga\Config\Config; use \Icinga\Application\Config;
/** /**
* *