From 93ae6d68116091e814a8d7b8fcfe52fe5cc6bb42 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 12 Aug 2013 15:02:25 +0200 Subject: [PATCH] Framework: mv Icinga\Config\Config to Icinga\Application\Config refs #4543 --- .../controllers/DashboardController.php | 2 +- .../forms/Authentication/SettingsForm.php | 2 +- application/forms/Dashboard/AddUrlForm.php | 2 +- doc/CONFIG.md | 4 ++-- .../Application/ApplicationBootstrap.php | 2 +- .../Icinga/{Config => Application}/Config.php | 12 +++++----- library/Icinga/Application/Modules/Module.php | 2 +- .../Backend/LdapUserBackend.php | 2 +- library/Icinga/Authentication/Manager.php | 2 +- library/Icinga/Backend.php | 2 +- library/Icinga/Protocol/Ldap/Connection.php | 2 +- library/Icinga/Web/ActionController.php | 2 +- library/Icinga/Web/ModuleActionController.php | 2 +- library/Icinga/Web/Widget/Dashboard.php | 2 +- .../controllers/CommandController.php | 2 +- .../monitoring/library/Monitoring/Backend.php | 2 +- .../library/Monitoring/Environment.php | 2 +- .../controllers/IndexControllerTest.php | 2 +- .../{ => Application}/Config/files/config.ini | 0 .../{ => Application}/Config/files/extra.ini | 0 .../Config/files/modules/amodule/config.ini | 0 .../Config/files/modules/amodule/extra.ini | 0 .../{Config => Application}/ConfigTest.php | 22 ++++++++++++++----- .../Authentication/DbUserBackendTest.php | 4 ++-- 24 files changed, 42 insertions(+), 32 deletions(-) rename library/Icinga/{Config => Application}/Config.php (98%) mode change 100755 => 100644 rename test/php/library/Icinga/{ => Application}/Config/files/config.ini (100%) rename test/php/library/Icinga/{ => Application}/Config/files/extra.ini (100%) rename test/php/library/Icinga/{ => Application}/Config/files/modules/amodule/config.ini (100%) rename test/php/library/Icinga/{ => Application}/Config/files/modules/amodule/extra.ini (100%) rename test/php/library/Icinga/{Config => Application}/ConfigTest.php (82%) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 2182fb793..864eb1281 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -31,7 +31,7 @@ use Icinga\Web\ActionController; use Icinga\Web\Url; use Icinga\Application\Icinga; use Icinga\Web\Widget\Dashboard; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Form\Dashboard\AddUrlForm; use Icinga\Exception\ConfigurationError; diff --git a/application/forms/Authentication/SettingsForm.php b/application/forms/Authentication/SettingsForm.php index df87e8afe..031995fc3 100644 --- a/application/forms/Authentication/SettingsForm.php +++ b/application/forms/Authentication/SettingsForm.php @@ -28,7 +28,7 @@ namespace Icinga\Web\Form; use Icinga\Web\Form; use Icinga\Web\Session; use Icinga\Web\Notification; -use Icinga\Config\Config; +use \Icinga\Application\Config; /** * Class SettingsForm diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/AddUrlForm.php index 571891ac7..4e245d58e 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/AddUrlForm.php @@ -2,7 +2,7 @@ namespace Icinga\Form\Dashboard; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Web\Form; use Icinga\Web\Widget\Dashboard; use Zend_Form_Element_Text; diff --git a/doc/CONFIG.md b/doc/CONFIG.md index 1085c61ec..5ebaa607b 100644 --- a/doc/CONFIG.md +++ b/doc/CONFIG.md @@ -1,13 +1,13 @@ # 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 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 keep their main configuration in the INI file called config.ini. Here's some example code: global->get('defaultTimezone', 'Europe/Berlin'); diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index a5890aae6..734632f94 100755 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -31,7 +31,7 @@ namespace Icinga\Application; use Icinga\Application\Modules\Manager as ModuleManager; use Icinga\Application\Platform; use Icinga\Exception\ProgrammingError; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Zend_Loader_Autoloader; use Icinga\Exception\ConfigurationError; diff --git a/library/Icinga/Config/Config.php b/library/Icinga/Application/Config.php old mode 100755 new mode 100644 similarity index 98% rename from library/Icinga/Config/Config.php rename to library/Icinga/Application/Config.php index a9f80c12d..25e85eada --- a/library/Icinga/Config/Config.php +++ b/library/Icinga/Application/Config.php @@ -2,31 +2,31 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - Head for multiple monitoring backends. * Copyright (C) 2013 Icinga Development Team - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * + * * @copyright 2013 Icinga Development Team * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Config; +namespace Icinga\Application; use Zend_Config_Ini; diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 530c1ace4..40ce159b0 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -29,7 +29,7 @@ namespace Icinga\Application\Modules; use Icinga\Application\ApplicationBootstrap; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Icinga\Application\Icinga; use Icinga\Web\Hook; use Zend_Controller_Router_Route as Route; diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 2892e1c57..0161368f8 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -32,7 +32,7 @@ use Icinga\User; use Icinga\Authentication\UserBackend; use Icinga\Authentication\Credentials; use Icinga\Protocol\Ldap; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; /** * User authentication backend (@see Icinga\Authentication\UserBackend) for diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index f3ef103cd..b1e45c3f4 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -29,7 +29,7 @@ namespace Icinga\Authentication; use Icinga\Application\Logger; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Exception\ConfigurationError as ConfigError; use Icinga\User; diff --git a/library/Icinga/Backend.php b/library/Icinga/Backend.php index ef347915f..170abf192 100755 --- a/library/Icinga/Backend.php +++ b/library/Icinga/Backend.php @@ -2,7 +2,7 @@ namespace Icinga; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Authentication\Manager as AuthManager; class Backend diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 9c6a73a69..2f9e0b832 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -6,7 +6,7 @@ namespace Icinga\Protocol\Ldap; use Icinga\Application\Platform; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Icinga\Application\Logger as Log; /** diff --git a/library/Icinga/Web/ActionController.php b/library/Icinga/Web/ActionController.php index 0b24384da..5e29ed207 100755 --- a/library/Icinga/Web/ActionController.php +++ b/library/Icinga/Web/ActionController.php @@ -31,7 +31,7 @@ namespace Icinga\Web; use Icinga\Authentication\Manager as AuthManager; use Icinga\Application\Benchmark; use Icinga\Exception; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Icinga\Web\Notification; use Zend_Layout as ZfLayout; use Zend_Controller_Action as ZfController; diff --git a/library/Icinga/Web/ModuleActionController.php b/library/Icinga/Web/ModuleActionController.php index dd19af17b..f338ad803 100644 --- a/library/Icinga/Web/ModuleActionController.php +++ b/library/Icinga/Web/ModuleActionController.php @@ -28,7 +28,7 @@ */ namespace Icinga\Web; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Application\Icinga; /** diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 2681c93e8..7500246aa 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -29,7 +29,7 @@ namespace Icinga\Web\Widget; use Icinga\Application\Icinga; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; use Icinga\Web\Widget\Widget; diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index a18aa42ec..651969235 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -31,7 +31,7 @@ use Icinga\Application\Benchmark; use Icinga\Application\Icinga; use Icinga\Backend; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Authentication\Manager; use Icinga\Web\Form; diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index 29fcebbb7..aaf9f2db3 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -2,7 +2,7 @@ namespace Monitoring; -use Icinga\Config\Config as IcingaConfig; +use \Icinga\Application\Config as IcingaConfig; use Icinga\Authentication\Manager as AuthManager; use Exception; diff --git a/modules/monitoring/library/Monitoring/Environment.php b/modules/monitoring/library/Monitoring/Environment.php index b4a67b7c6..cef5dea8e 100644 --- a/modules/monitoring/library/Monitoring/Environment.php +++ b/modules/monitoring/library/Monitoring/Environment.php @@ -2,7 +2,7 @@ namespace Monitoring; -use Icinga\Config\Config; +use \Icinga\Application\Config; use Icinga\Web\Session; use Exception; diff --git a/test/php/application/controllers/IndexControllerTest.php b/test/php/application/controllers/IndexControllerTest.php index d418aa72e..2b3504928 100644 --- a/test/php/application/controllers/IndexControllerTest.php +++ b/test/php/application/controllers/IndexControllerTest.php @@ -10,7 +10,7 @@ require 'Zend/Controller/Action.php'; require '../../library/Icinga/Exception/ProgrammingError.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/Web/ActionController.php'; require '../../library/Icinga/Web/Notification.php'; diff --git a/test/php/library/Icinga/Config/files/config.ini b/test/php/library/Icinga/Application/Config/files/config.ini similarity index 100% rename from test/php/library/Icinga/Config/files/config.ini rename to test/php/library/Icinga/Application/Config/files/config.ini diff --git a/test/php/library/Icinga/Config/files/extra.ini b/test/php/library/Icinga/Application/Config/files/extra.ini similarity index 100% rename from test/php/library/Icinga/Config/files/extra.ini rename to test/php/library/Icinga/Application/Config/files/extra.ini diff --git a/test/php/library/Icinga/Config/files/modules/amodule/config.ini b/test/php/library/Icinga/Application/Config/files/modules/amodule/config.ini similarity index 100% rename from test/php/library/Icinga/Config/files/modules/amodule/config.ini rename to test/php/library/Icinga/Application/Config/files/modules/amodule/config.ini diff --git a/test/php/library/Icinga/Config/files/modules/amodule/extra.ini b/test/php/library/Icinga/Application/Config/files/modules/amodule/extra.ini similarity index 100% rename from test/php/library/Icinga/Config/files/modules/amodule/extra.ini rename to test/php/library/Icinga/Application/Config/files/modules/amodule/extra.ini diff --git a/test/php/library/Icinga/Config/ConfigTest.php b/test/php/library/Icinga/Application/ConfigTest.php similarity index 82% rename from test/php/library/Icinga/Config/ConfigTest.php rename to test/php/library/Icinga/Application/ConfigTest.php index 026389667..6a7677a3c 100644 --- a/test/php/library/Icinga/Config/ConfigTest.php +++ b/test/php/library/Icinga/Application/ConfigTest.php @@ -2,27 +2,37 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} - namespace Tests\Icinga\Application; 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 { + /** + * Set up config dir + * + * Utilizes singleton IcingaConfig + * + * @backupStaticAttributes enabled + */ public function setUp() { - IcingaConfig::$configDir = dirname(__FILE__) . '/files'; + IcingaConfig::$configDir = dirname(__FILE__) . '/Config/files'; } public function testAppConfig() { $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 - $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 $this->assertEquals(0, $config->logging->get('disable', 0)); // Test retrieve full section diff --git a/test/php/library/Icinga/Authentication/DbUserBackendTest.php b/test/php/library/Icinga/Authentication/DbUserBackendTest.php index f1cee60a0..72a8bdecb 100644 --- a/test/php/library/Icinga/Authentication/DbUserBackendTest.php +++ b/test/php/library/Icinga/Authentication/DbUserBackendTest.php @@ -36,7 +36,7 @@ require_once('Zend/Config/Ini.php'); require_once('Zend/Db.php'); require_once('../../library/Icinga/Authentication/UserBackend.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/Backend/DbUserBackend.php'); require_once('../../library/Icinga/User.php'); @@ -45,7 +45,7 @@ use Icinga\Authentication\Backend\DbUserBackend; use Icinga\Util\Crypto; use Icinga\Authentication\Credentials; use Icinga\User; -use Icinga\Config\Config; +use \Icinga\Application\Config; /** *