From ccae70bc80c319328d87e358e8a2270c5dbc8a29 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 10 Apr 2014 10:32:50 +0200 Subject: [PATCH] Make all tests inherit from BaseTestCase and fix license headers and style refs #4639 --- library/Icinga/Test/BaseTestCase.php | 37 +----- .../controllers/IndexControllerTest.php | 15 +-- .../forms/Config/AuthenticationFormTest.php | 59 +--------- .../forms/Config/GeneralFormTest.php | 25 ---- .../forms/Config/LoggingFormTest.php | 28 ----- .../forms/Preference/GeneralFormTest.php | 27 ----- .../library/Icinga/Application/ConfigTest.php | 28 +---- .../library/Icinga/Application/LoaderTest.php | 5 +- .../library/Icinga/Application/LoggerTest.php | 28 +---- .../Icinga/Application/Modules/Manager.php | 21 ++-- .../library/Icinga/Application/ZendDbMock.php | 27 +---- .../Authentication/DbUserBackendTest.php | 26 ---- .../Authentication/LdapUserBackendTest.php | 25 ---- .../Icinga/Authentication/ManagerTest.php | 26 ---- .../library/Icinga/Chart/GraphChartTest.php | 26 ---- .../php/library/Icinga/Chart/PieChartTest.php | 26 ---- .../Icinga/Config/PreservingIniWriterTest.php | 32 +---- test/php/library/Icinga/Filter/DomainTest.php | 25 ---- test/php/library/Icinga/Filter/FilterTest.php | 25 ---- .../Icinga/Filter/QueryHandlerTest.php | 26 ---- .../Icinga/Filter/Type/BooleanFilterTest.php | 25 ---- .../Icinga/Filter/Type/TextSearchTest.php | 25 ---- .../Filter/Type/TimeRangeSpecifierTest.php | 25 ---- .../Protocol/Commandpipe/CommandPipeTest.php | 29 +---- .../Icinga/Protocol/Ldap/QueryTest.php | 111 +----------------- .../Component/StatusdatComponentTest.php | 7 +- .../Statusdat/Exceptions/ParsingException.php | 3 +- .../Icinga/Protocol/Statusdat/ParserTest.php | 9 +- .../Statusdat/Query/ExpressionTest.php | 6 +- .../Protocol/Statusdat/Query/GroupTest.php | 74 ++++++++---- .../Icinga/Protocol/Statusdat/QueryTest.php | 6 +- .../Icinga/Protocol/Statusdat/ReaderMock.php | 10 +- .../Icinga/Protocol/Statusdat/ReaderTest.php | 13 +- .../Statusdat/RuntimeStateContainerTest.php | 12 +- .../library/Icinga/Session/PhpSessionTest.php | 25 ---- .../Icinga/Session/SessionNamespaceTest.php | 26 ---- .../Icinga/Test/BaseTestCaseDbTest.php | 36 ------ test/php/library/Icinga/UserTest.php | 23 ++-- .../php/library/Icinga/Util/DimensionTest.php | 22 +--- .../Web/Form/Element/DateTimePickerTest.php | 2 + .../Validator/DateFormatValidatorTest.php | 30 +---- .../Validator/TimeFormatValidatorTest.php | 29 +---- .../Validator/WritablePathValidatorTest.php | 29 +---- test/php/library/Icinga/Web/FormTest.php | 7 +- .../ConfigurationTabBuilderTest.php | 20 ++-- .../Configuration/ConfigurationTabTest.php | 5 +- test/php/library/Icinga/Web/HookTest.php | 38 +----- .../library/Icinga/Web/NotificationTest.php | 10 +- .../Paginator/Adapter/QueryAdapterTest.php | 10 +- .../ScrollingStyle/SlidingWithBorderTest.php | 9 +- test/php/library/Icinga/Web/RequestMock.php | 29 +---- test/php/library/Icinga/Web/UrlTest.php | 62 ++++++---- test/php/library/Icinga/Web/ViewMock.php | 35 ------ .../php/library/Icinga/Web/Widget/TabTest.php | 29 +---- .../library/Icinga/Web/Widget/TabsTest.php | 29 +---- test/php/regression/Bug4102Test.php | 4 +- 56 files changed, 246 insertions(+), 1155 deletions(-) diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index 5b0dd71fe..9d104c749 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace { @@ -48,12 +23,12 @@ namespace Icinga\Test { use \Exception; use \RuntimeException; - use Zend_Test_PHPUnit_ControllerTestCase; - use Zend_Config; - use Zend_Db_Adapter_Pdo_Abstract; - use Zend_Db_Adapter_Pdo_Mysql; - use Zend_Db_Adapter_Pdo_Pgsql; - use Zend_Db_Adapter_Pdo_Oci; + use \Zend_Test_PHPUnit_ControllerTestCase; + use \Zend_Config; + use \Zend_Db_Adapter_Pdo_Abstract; + use \Zend_Db_Adapter_Pdo_Mysql; + use \Zend_Db_Adapter_Pdo_Pgsql; + use \Zend_Db_Adapter_Pdo_Oci; use Icinga\Data\ResourceFactory; use Icinga\User\Preferences; use Icinga\Web\Form; diff --git a/test/php/application/controllers/IndexControllerTest.php b/test/php/application/controllers/IndexControllerTest.php index 06550063c..74734f623 100644 --- a/test/php/application/controllers/IndexControllerTest.php +++ b/test/php/application/controllers/IndexControllerTest.php @@ -1,16 +1,17 @@ applicationPath = realpath(__DIR__. '/../../../../application'); - if (!defined('APPLICATION_PATH')) { - define('APPLICATION_PATH', $this->applicationPath); + define('APPLICATION_PATH', BaseTestCase::$appDir); } if (!defined('APPLICATION_ENV')) { @@ -25,7 +26,7 @@ class IndexControllerTest extends \Zend_Test_PHPUnit_ControllerTestCase { public function appBootstrap() { - $this->getFrontController()->setControllerDirectory($this->applicationPath. '/controllers'); + $this->getFrontController()->setControllerDirectory(BaseTestCase::$appDir . '/controllers'); } public function testIndexAction() diff --git a/test/php/application/forms/Config/AuthenticationFormTest.php b/test/php/application/forms/Config/AuthenticationFormTest.php index ecd8e2da7..6e8347846 100644 --- a/test/php/application/forms/Config/AuthenticationFormTest.php +++ b/test/php/application/forms/Config/AuthenticationFormTest.php @@ -1,74 +1,19 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Form\Config; -use Icinga\Test\BaseTestCase; - use \Zend_Config; -use \Icinga\Web\Url; +use Icinga\Web\Url; +use Icinga\Test\BaseTestCase; use Tests\Icinga\Web\RequestMock; /** * Test for the authentication provider form - * */ class AuthenticationFormTest extends BaseTestCase { - /** - * Return a test configuration containing a database and a ldap backend - * - * @return Zend_Config - */ - private function getTestConfig() - { - return new Zend_Config( - array( - 'test-db' => array( - 'backend' => 'db', - 'target' => 'user', - 'resource' => 'db_resource' - ), - 'test-ldap' => array( - 'backend' => 'ldap', - 'target' => 'user', - 'hostname' => 'test host', - 'root_dn' => 'ou=test,dc=icinga,dc=org', - 'bind_dn' => 'cn=testuser,cn=config', - 'bind_pw' => 'password', - 'user_class' => 'testClass', - 'user_name_attribute' => 'testAttribute' - ) - ) - ); - } - /** * Test the ldap provider form population from config */ diff --git a/test/php/application/forms/Config/GeneralFormTest.php b/test/php/application/forms/Config/GeneralFormTest.php index 276d2ee7b..1d95f0e6e 100644 --- a/test/php/application/forms/Config/GeneralFormTest.php +++ b/test/php/application/forms/Config/GeneralFormTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Form\Config; diff --git a/test/php/application/forms/Config/LoggingFormTest.php b/test/php/application/forms/Config/LoggingFormTest.php index 50632afa2..6bc22f824 100644 --- a/test/php/application/forms/Config/LoggingFormTest.php +++ b/test/php/application/forms/Config/LoggingFormTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Form\Config; @@ -34,13 +9,11 @@ Use Icinga\Test\BaseTestCase; /** * Test for the authentication provider form - * */ class LoggingFormTest extends BaseTestCase { /** * Test the logging form to be correctly populated from configuration - * */ public function testLoggingFormPopulation() { @@ -88,7 +61,6 @@ class LoggingFormTest extends BaseTestCase /** * Test the logging form to create correct modified configurations when submit - * */ public function testCorrectConfigCreation() { diff --git a/test/php/application/forms/Preference/GeneralFormTest.php b/test/php/application/forms/Preference/GeneralFormTest.php index b66cb6480..ddffa70f9 100644 --- a/test/php/application/forms/Preference/GeneralFormTest.php +++ b/test/php/application/forms/Preference/GeneralFormTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Form\Preference; @@ -42,7 +17,6 @@ class GeneralFormTest extends BaseTestCase { /** * Test whether fields using the default values have input disabled - * */ public function testDisableFormIfUsingDefault() { @@ -60,7 +34,6 @@ class GeneralFormTest extends BaseTestCase /** * Test whether fields with preferences are enabled - * */ public function testEnableFormIfUsingPreference() { diff --git a/test/php/library/Icinga/Application/ConfigTest.php b/test/php/library/Icinga/Application/ConfigTest.php index 61264b131..b168d6e53 100644 --- a/test/php/library/Icinga/Application/ConfigTest.php +++ b/test/php/library/Icinga/Application/ConfigTest.php @@ -1,37 +1,13 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Application; +use Icinga\Test\BaseTestCase; use \Icinga\Application\Config as IcingaConfig; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends BaseTestCase { /** * Set up config dir diff --git a/test/php/library/Icinga/Application/LoaderTest.php b/test/php/library/Icinga/Application/LoaderTest.php index 9bf220e32..3d9695ec1 100644 --- a/test/php/library/Icinga/Application/LoaderTest.php +++ b/test/php/library/Icinga/Application/LoaderTest.php @@ -1,10 +1,13 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Application; - use \Zend_Config; -use Icinga\Test\BaseTestCase; use Icinga\Logger\Logger; +use Icinga\Test\BaseTestCase; class LoggerTest extends BaseTestCase { diff --git a/test/php/library/Icinga/Application/Modules/Manager.php b/test/php/library/Icinga/Application/Modules/Manager.php index bb7e5e2ad..6395faa2f 100644 --- a/test/php/library/Icinga/Application/Modules/Manager.php +++ b/test/php/library/Icinga/Application/Modules/Manager.php @@ -1,7 +1,10 @@ markTestSkipped("Temporary folder not writable for this user"); return; } - if (is_dir($moduleDir."/enabledModules")) { + if (is_dir($moduleDir . "/enabledModules")) { exec("rm -r $moduleDir/enabledModules"); } - mkdir($moduleDir."/enabledModules"); + mkdir($moduleDir . "/enabledModules"); } public function testDetectEnabledModules() @@ -43,11 +46,11 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $manager = new ModuleManager(null, "/tmp/enabledModules", array("none")); $this->assertEmpty($manager->listEnabledModules()); - symlink(getcwd()."/res/testModules/module1", "/tmp/enabledModules/module1"); + symlink(getcwd() . "/res/testModules/module1", "/tmp/enabledModules/module1"); $manager = new ModuleManager(null, "/tmp/enabledModules", array("none")); $this->assertEquals(array("module1"), $manager->listEnabledModules()); - symlink(getcwd()."/res/testModules/module2", "/tmp/enabledModules/module2"); - symlink(getcwd()."/res/???", "/tmp/enabledModules/module3"); + symlink(getcwd() . "/res/testModules/module2", "/tmp/enabledModules/module2"); + symlink(getcwd() . "/res/???", "/tmp/enabledModules/module3"); $manager = new ModuleManager(null, "/tmp/enabledModules", array("none")); $this->assertEquals(array("module1", "module2"), $manager->listEnabledModules()); } @@ -67,7 +70,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testEnableModule() { - $manager = new ModuleManager(null, "/tmp/enabledModules", array(getcwd()."/res/testModules")); + $manager = new ModuleManager(null, "/tmp/enabledModules", array(getcwd() . "/res/testModules")); $this->assertEmpty($manager->listEnabledModules()); $manager->enableModule("module1"); $elems = $manager->listEnabledModules(); @@ -82,8 +85,8 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testDisableModule() { clearstatcache(true); - symlink(getcwd()."/res/testModules/module1", "/tmp/enabledModules/module1"); - $manager = new ModuleManager(null, "/tmp/enabledModules", array(getcwd()."/res/testModules")); + symlink(getcwd() . "/res/testModules/module1", "/tmp/enabledModules/module1"); + $manager = new ModuleManager(null, "/tmp/enabledModules", array(getcwd() . "/res/testModules")); $elems = $manager->listEnabledModules(); $this->assertNotEmpty($elems); $this->assertEquals($elems[0], "module1"); diff --git a/test/php/library/Icinga/Application/ZendDbMock.php b/test/php/library/Icinga/Application/ZendDbMock.php index 281119296..d8a2aac7c 100644 --- a/test/php/library/Icinga/Application/ZendDbMock.php +++ b/test/php/library/Icinga/Application/ZendDbMock.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Application; @@ -53,7 +28,7 @@ class ZendDbMock * * @param $adapter String name of base adapter class, or Zend_Config object * @param $config mixed OPTIONAL; an array or Zend_Config object with adapter - * parameters + * parameters * * @return stdClass Empty object */ diff --git a/test/php/library/Icinga/Authentication/DbUserBackendTest.php b/test/php/library/Icinga/Authentication/DbUserBackendTest.php index 35bf109d2..bcfced590 100644 --- a/test/php/library/Icinga/Authentication/DbUserBackendTest.php +++ b/test/php/library/Icinga/Authentication/DbUserBackendTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Authentication; @@ -289,5 +264,4 @@ class DbUserBackendTest extends BaseTestCase $this->assertGreaterThan(0, $backend->getUserCount()); } - } diff --git a/test/php/library/Icinga/Authentication/LdapUserBackendTest.php b/test/php/library/Icinga/Authentication/LdapUserBackendTest.php index 1c2295ae8..01d3d8fe3 100644 --- a/test/php/library/Icinga/Authentication/LdapUserBackendTest.php +++ b/test/php/library/Icinga/Authentication/LdapUserBackendTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Authentication; diff --git a/test/php/library/Icinga/Authentication/ManagerTest.php b/test/php/library/Icinga/Authentication/ManagerTest.php index 8252201ee..03ba70fc3 100644 --- a/test/php/library/Icinga/Authentication/ManagerTest.php +++ b/test/php/library/Icinga/Authentication/ManagerTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Authentication; @@ -58,7 +33,6 @@ class ManagerTest extends BaseTestCase &$session = null, $write = false, $nobackend = false, - Zend_Config $managerConfig = null ) { if ($session == null) { diff --git a/test/php/library/Icinga/Chart/GraphChartTest.php b/test/php/library/Icinga/Chart/GraphChartTest.php index 72418c402..25870791a 100644 --- a/test/php/library/Icinga/Chart/GraphChartTest.php +++ b/test/php/library/Icinga/Chart/GraphChartTest.php @@ -1,37 +1,11 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Chart; use \DOMXPath; use \DOMDocument; - use Icinga\Chart\GridChart; use Icinga\Test\BaseTestCase; diff --git a/test/php/library/Icinga/Chart/PieChartTest.php b/test/php/library/Icinga/Chart/PieChartTest.php index bf92eae25..c09f29e57 100644 --- a/test/php/library/Icinga/Chart/PieChartTest.php +++ b/test/php/library/Icinga/Chart/PieChartTest.php @@ -1,37 +1,11 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Chart; use \DOMXPath; use \DOMDocument; - use Icinga\Chart\PieChart; use Icinga\Test\BaseTestCase; diff --git a/test/php/library/Icinga/Config/PreservingIniWriterTest.php b/test/php/library/Icinga/Config/PreservingIniWriterTest.php index f57066275..946ae0057 100644 --- a/test/php/library/Icinga/Config/PreservingIniWriterTest.php +++ b/test/php/library/Icinga/Config/PreservingIniWriterTest.php @@ -1,39 +1,15 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Tests\Icinga\PreservingIniWriterTest; +namespace Tests\Icinga\Config; use \Zend_Config; +use Icinga\Test\BaseTestCase; use Icinga\Config\PreservingIniWriter; -class PreservingIniWriterTest extends \PHPUnit_Framework_TestCase { - +class PreservingIniWriterTest extends BaseTestCase +{ private $tmpfiles = array(); /** diff --git a/test/php/library/Icinga/Filter/DomainTest.php b/test/php/library/Icinga/Filter/DomainTest.php index 3b87ed87c..a48233866 100644 --- a/test/php/library/Icinga/Filter/DomainTest.php +++ b/test/php/library/Icinga/Filter/DomainTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; diff --git a/test/php/library/Icinga/Filter/FilterTest.php b/test/php/library/Icinga/Filter/FilterTest.php index ad3fbbaee..a002ec500 100644 --- a/test/php/library/Icinga/Filter/FilterTest.php +++ b/test/php/library/Icinga/Filter/FilterTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; diff --git a/test/php/library/Icinga/Filter/QueryHandlerTest.php b/test/php/library/Icinga/Filter/QueryHandlerTest.php index e88296388..a5749cf67 100644 --- a/test/php/library/Icinga/Filter/QueryHandlerTest.php +++ b/test/php/library/Icinga/Filter/QueryHandlerTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; @@ -48,7 +23,6 @@ class TypeMock extends FilterType return $node; } - public function getProposalsForQuery($query) { return $this->getOperators(); diff --git a/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php b/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php index c74c63e6d..27057b987 100644 --- a/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php +++ b/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; diff --git a/test/php/library/Icinga/Filter/Type/TextSearchTest.php b/test/php/library/Icinga/Filter/Type/TextSearchTest.php index fc5d3dab5..07a7126d0 100644 --- a/test/php/library/Icinga/Filter/Type/TextSearchTest.php +++ b/test/php/library/Icinga/Filter/Type/TextSearchTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; diff --git a/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php b/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php index 5312ad14a..c9b813e12 100644 --- a/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php +++ b/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Filter; diff --git a/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php b/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php index 08814b316..b65e202c6 100644 --- a/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php +++ b/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php @@ -1,36 +1,11 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Protocol\Commandpipe; use \Zend_Config; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Icinga\Protocol\Commandpipe\Comment; use Icinga\Protocol\Commandpipe\CommandPipe; use Icinga\Protocol\Commandpipe\PropertyModifier as MONFLAG; @@ -53,7 +28,7 @@ if (!defined('EXTCMD_TEST_BIN')) { * Uses the helper script extcmd_test, which is basically the extracted command * parser functions from the icinga core */ -class CommandPipeTest extends PHPUnit_Framework_TestCase +class CommandPipeTest extends BaseTestCase { /** * Return the path of the test pipe used in these tests diff --git a/test/php/library/Icinga/Protocol/Ldap/QueryTest.php b/test/php/library/Icinga/Protocol/Ldap/QueryTest.php index 11bb011eb..0fa155202 100644 --- a/test/php/library/Icinga/Protocol/Ldap/QueryTest.php +++ b/test/php/library/Icinga/Protocol/Ldap/QueryTest.php @@ -5,8 +5,10 @@ namespace Tests\Icinga\Protocol\Ldap; use \Zend_Config; +use Icinga\Test\BaseTestCase; +use Icinga\Protocol\Ldap\Connection; -class QueryTest extends \PHPUnit_Framework_TestCase +class QueryTest extends BaseTestCase { private function emptySelect() { @@ -19,7 +21,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ) ); - $connection = new \Icinga\Protocol\Ldap\Connection($config); + $connection = new Connection($config); return $connection->select(); } @@ -35,18 +37,6 @@ class QueryTest extends \PHPUnit_Framework_TestCase return $select; } - /** - * Test for Query::Count() - shall be tested with connection - * - **/ - public function testCount() - { - } - - /** - * Test for Query::Limit() - * - **/ public function testLimit() { $select = $this->prepareSelect(); @@ -54,10 +44,6 @@ class QueryTest extends \PHPUnit_Framework_TestCase $this->assertEquals(4, $select->getOffset()); } - /** - * Test for Query::HasLimit() - * - **/ public function testHasLimit() { $select = $this->emptySelect(); @@ -66,10 +52,6 @@ class QueryTest extends \PHPUnit_Framework_TestCase $this->assertTrue($select->hasLimit()); } - /** - * Test for Query::HasOffset() - * - **/ public function testHasOffset() { $select = $this->emptySelect(); @@ -78,99 +60,39 @@ class QueryTest extends \PHPUnit_Framework_TestCase $this->assertTrue($select->hasOffset()); } - /** - * Test for Query::GetLimit() - * - **/ public function testGetLimit() { $select = $this->prepareSelect(); $this->assertEquals(10, $select->getLimit()); } - /** - * Test for Query::GetOffset() - * - **/ public function testGetOffset() { $select = $this->prepareSelect(); $this->assertEquals(10, $select->getLimit()); } - /** - * Test for Query::FetchTree() - * - **/ public function testFetchTree() { $this->markTestIncomplete('testFetchTree is not implemented yet - requires real LDAP'); } - /** - * Test for Query::FetchAll() - shall be tested with connection - * - **/ - public function testFetchAll() - { - } - - /** - * Test for Query::FetchRow() - shall be tested with connection - * - **/ - public function testFetchRow() - { - } - - /** - * Test for Query::FetchOne() - * - **/ - public function testFetchOne() - { - } - - /** - * Test for Query::FetchPairs() - * - **/ - public function testFetchPairs() - { - } - - /** - * Test for Query::From() - * - **/ public function testFrom() { return $this->testListFields(); } - /** - * Test for Query::Where() - * - **/ public function testWhere() { $this->markTestIncomplete('testWhere is not implemented yet'); } - /** - * Test for Query::Order() - * - **/ public function testOrder() { $select = $this->emptySelect()->order('bla'); // tested by testGetSortColumns } - /** - * Test for Query::ListFields() - * - **/ public function testListFields() { $select = $this->prepareSelect(); @@ -180,10 +102,6 @@ class QueryTest extends \PHPUnit_Framework_TestCase ); } - /** - * Test for Query::GetSortColumns() - * - **/ public function testGetSortColumns() { $select = $this->prepareSelect(); @@ -191,31 +109,10 @@ class QueryTest extends \PHPUnit_Framework_TestCase $this->assertEquals('testIntColumn', $cols[0][0]); } - /** - * Test for Query::Paginate() - requires real result - * - **/ - public function testPaginate() - { - } - - /** - * Test for Query::__toString() - * - **/ public function test__toString() { $select = $this->prepareSelect(); $res = '(&(objectClass=dummyClass)(testIntColumn=1)(testStringColumn=test)(testWildcard=abc*))'; $this->assertEquals($res, (string) $select); } - - /** - * Test for Query::__destruct() - * - **/ - public function test__destruct() - { - } - } diff --git a/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php b/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php index bc4752016..77ddcdab0 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php @@ -1,15 +1,18 @@ getReader(); $group = array(array('exc-hostb')); - $result = $r->select()->from("services")->where("host.group IN ?",$group)->getResult(); + $result = $r->select()->from("services")->where("host.group IN ?", $group)->getResult(); $this->assertCount(9, $result); foreach($result as $obj) { diff --git a/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php b/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php index 8a206c1bc..941627b1c 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php @@ -1,8 +1,9 @@ markTestSkipped('Skipped slow tests'); $objects = fopen("./res/status/icinga.objects.cache","r"); $status = fopen("./res/status/icinga.status.dat","r"); $testParser = new Parser($objects); diff --git a/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php b/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php index 2391afdcc..d7ee0546b 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php @@ -1,10 +1,13 @@ markTestIncomplete('testFilter is not implemented yet'); } - } diff --git a/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php b/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php index 69298e080..cbb645fa4 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php @@ -1,8 +1,11 @@ fromString("numeric_val >= ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString( + "numeric_val >= ?", + $value, + "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock" + ); $this->assertCount(1, $testQuery->getItems()); $this->assertCount(0, $value); @@ -53,9 +60,13 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testParsingSimpleAndCondition() { - $testQuery = new Statusdat\Query\Group(); + $testQuery = new Group(); $value = array(4, 'hosta'); - $testQuery->fromString("numeric_val >= ? AND host_name = ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString( + "numeric_val >= ? AND host_name = ?", + $value, + "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock" + ); $this->assertCount(2, $testQuery->getItems()); $this->assertCount(0, $value); $this->assertEquals("AND", $testQuery->getType()); @@ -72,9 +83,13 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testParsingSimpleORCondition() { - $testQuery = new Statusdat\Query\Group(); + $testQuery = new Group(); $value = array(4, 'hosta'); - $testQuery->fromString("numeric_val >= ? OR host_name = ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString( + "numeric_val >= ? OR host_name = ?", + $value, + "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock" + ); $this->assertCount(2, $testQuery->getItems()); $this->assertCount(0, $value); $this->assertEquals("OR", $testQuery->getType()); @@ -91,9 +106,13 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testParsingExplicitSubgroup() { - $testQuery = new Statusdat\Query\Group(); + $testQuery = new Group(); $value = array(4, 'service1', 'hosta'); - $testQuery->fromString("numeric_val >= ? AND (service_description = ? OR host_name = ?)", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString( + "numeric_val >= ? AND (service_description = ? OR host_name = ?)", + $value, + "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock" + ); $this->assertCount(2, $testQuery->getItems()); $this->assertCount(0, $value); $this->assertEquals("AND", $testQuery->getType()); @@ -119,9 +138,13 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testParsingImplicitSubgroup() { - $testQuery = new Statusdat\Query\Group(); + $testQuery = new Group(); $value = array(4, 'service1', 'hosta'); - $testQuery->fromString("numeric_val >= ? AND service_description = ? OR host_name = ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString( + "numeric_val >= ? AND service_description = ? OR host_name = ?", + $value, + "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock" + ); $this->assertCount(2, $testQuery->getItems()); $this->assertCount(0, $value); $this->assertEquals("AND", $testQuery->getType()); @@ -147,35 +170,41 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testAndFilter() { - $testQuery = new Statusdat\Query\Group(); - $testQuery->setType(Statusdat\Query\Group::TYPE_AND); + $testQuery = new Group(); + $testQuery->setType(Group::TYPE_AND); $exp1 = new QueryExpressionMock(); $exp1->filter = array(1, 2, 3, 4, 5, 6, 8); $exp2 = new QueryExpressionMock(); $exp2->filter = array(3, 4, 8); $base = array(0, 1, 2, 3, 4, 5, 6, 7, 8); - $this->assertEquals(array(3, 4, 8), array_values($testQuery->addItem($exp1)->addItem($exp2)->filter($base))); + $this->assertEquals( + array(3, 4, 8), + array_values($testQuery->addItem($exp1)->addItem($exp2)->filter($base)) + ); } public function testOrFilter() { - $testQuery = new Statusdat\Query\Group(); - $testQuery->setType(Statusdat\Query\Group::TYPE_OR); + $testQuery = new Group(); + $testQuery->setType(Group::TYPE_OR); $exp1 = new QueryExpressionMock(); $exp1->filter = array(1, 2, 3); $exp2 = new QueryExpressionMock(); $exp2->filter = array(3, 4, 6, 8); $base = array(0, 1, 2, 3, 4, 5, 6, 7, 8); - $this->assertEquals(array(1, 2, 3, 4, 6, 8), array_values($testQuery->addItem($exp1)->addItem($exp2)->filter($base))); + $this->assertEquals( + array(1, 2, 3, 4, 6, 8), + array_values($testQuery->addItem($exp1)->addItem($exp2)->filter($base)) + ); } public function testCombinedFilter() { - $testQuery_and = new Statusdat\Query\Group(); - $testQuery_and->setType(Statusdat\Query\Group::TYPE_AND); - $testQuery_or = new Statusdat\Query\Group(); - $testQuery_or->setType(Statusdat\Query\Group::TYPE_OR); + $testQuery_and = new Group(); + $testQuery_and->setType(Group::TYPE_AND); + $testQuery_or = new Group(); + $testQuery_or->setType(Group::TYPE_OR); $base = array(0, 1, 2, 3, 4, 5, 6, 7, 8); $and_exp1 = new QueryExpressionMock(); @@ -196,4 +225,3 @@ class GroupTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php index 35481f28b..8eb85ee87 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php @@ -1,10 +1,13 @@ $this->objects, "indices" => $this->indices @@ -33,7 +35,7 @@ class ReaderMock implements IReader, DatasourceInterface return $this->objects; } - public function __call($arg1,$arg2) { + public function __call($arg1, $arg2) { return $this; } @@ -44,9 +46,9 @@ class ReaderMock implements IReader, DatasourceInterface public function getObjectByName($type, $idx) { - if (isset($this->objects[$type]) && isset($this->objects[$type][$idx])) + if (isset($this->objects[$type]) && isset($this->objects[$type][$idx])) { return $this->objects[$type][$idx]; - return null; + } } } diff --git a/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php b/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php index 39af49d74..167693119 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php @@ -1,15 +1,12 @@ setExpectedException("Icinga\Exception\ConfigurationError"); $parser = new ParserMock(); $reader = new Reader(new ConfigMock(array( diff --git a/test/php/library/Icinga/Protocol/Statusdat/RuntimeStateContainerTest.php b/test/php/library/Icinga/Protocol/Statusdat/RuntimeStateContainerTest.php index 93999e5d3..b66ecf817 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/RuntimeStateContainerTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/RuntimeStateContainerTest.php @@ -1,15 +1,17 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Session; diff --git a/test/php/library/Icinga/Session/SessionNamespaceTest.php b/test/php/library/Icinga/Session/SessionNamespaceTest.php index 1c8f48ce0..67e8eb466 100644 --- a/test/php/library/Icinga/Session/SessionNamespaceTest.php +++ b/test/php/library/Icinga/Session/SessionNamespaceTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Session; @@ -33,7 +8,6 @@ use \Exception; use Icinga\Test\BaseTestCase; use Icinga\Web\Session\SessionNamespace; - class SessionNamespaceTest extends BaseTestCase { /** diff --git a/test/php/library/Icinga/Test/BaseTestCaseDbTest.php b/test/php/library/Icinga/Test/BaseTestCaseDbTest.php index a1bae5777..1900550c6 100644 --- a/test/php/library/Icinga/Test/BaseTestCaseDbTest.php +++ b/test/php/library/Icinga/Test/BaseTestCaseDbTest.php @@ -1,30 +1,5 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Test; @@ -42,16 +17,6 @@ class BaseTestCaseDbTest extends BaseTestCase } } - public function testExistingTestDirectories() - { - $this->assertFileExists(self::$appDir); - $this->assertFileExists(self::$libDir); - $this->assertFileExists(self::$etcDir); - $this->assertFileExists(self::$testDir); - $this->assertFileExists(self::$moduleDir); - // $this->assertFileExists(self::$shareDir); - } - /** * @dataProvider mysqlDb */ @@ -67,7 +32,6 @@ class BaseTestCaseDbTest extends BaseTestCase public function testMySqlCreateTablePart1($resource) { $this->setupDbProvider($resource); - /** @var \Zend_Db_Adapter_Pdo_Abstract $resource **/ $resource->exec('CREATE TABLE test(uid INT NOT NULL PRIMARY KEY);'); $tables = $resource->listTables(); diff --git a/test/php/library/Icinga/UserTest.php b/test/php/library/Icinga/UserTest.php index c36529d6d..4e753308f 100644 --- a/test/php/library/Icinga/UserTest.php +++ b/test/php/library/Icinga/UserTest.php @@ -1,32 +1,31 @@ setPreferences($prefs); - $this->assertEquals($user->getTimeZone(), new DateTimeZone($defaultTz), + $this->assertEquals($user->getTimeZone(), new DateTimeZone(date_default_timezone_get()), 'User\'s timezone does not match the default timezone' ); } public function testGetTimezoneIfTimezoneSet() { - $defaultTz = 'UTC'; $explicitTz = 'Europe/Berlin'; - date_default_timezone_set($defaultTz); - $user = new IcingaUser('unittest'); - $prefs = new UserPreferences(array( + $user = new User('unittest'); + $prefs = new Preferences(array( 'timezone' => $explicitTz )); $user->setPreferences($prefs); diff --git a/test/php/library/Icinga/Util/DimensionTest.php b/test/php/library/Icinga/Util/DimensionTest.php index f987cc53f..d6678258f 100644 --- a/test/php/library/Icinga/Util/DimensionTest.php +++ b/test/php/library/Icinga/Util/DimensionTest.php @@ -1,19 +1,14 @@ assertEquals(Dimension::UNIT_PT, $d->getUnit(), "Asserting the unit of pt input to be correctly parsed"); } - /** - * Test string creation from Dimension - * - */ public function testStringCreation() { $d = new Dimension(1000, Dimension::UNIT_PX); @@ -46,9 +37,6 @@ class DimensionTest extends \PHPUnit_Framework_TestCase { $this->assertEquals("40pt", (string) $d, "Asserting float values being truncated by now"); } - /** - * - */ public function testInvalidDimensions() { $d = new Dimension(-20, Dimension::UNIT_PX); diff --git a/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php b/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php index 363b87fad..dd4843bb0 100644 --- a/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php +++ b/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php @@ -1,4 +1,6 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web\Form\Validator; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Icinga\Web\Form\Validator\DateFormatValidator; -class DateFormatValidatorTest extends PHPUnit_Framework_TestCase +class DateFormatValidatorTest extends BaseTestCase { - public function testValidateCorrectInput() { $validator = new DateFormatValidator(); diff --git a/test/php/library/Icinga/Web/Form/Validator/TimeFormatValidatorTest.php b/test/php/library/Icinga/Web/Form/Validator/TimeFormatValidatorTest.php index a456ec4e7..b0ad8c9ae 100644 --- a/test/php/library/Icinga/Web/Form/Validator/TimeFormatValidatorTest.php +++ b/test/php/library/Icinga/Web/Form/Validator/TimeFormatValidatorTest.php @@ -1,38 +1,13 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web\Form\Validator; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Icinga\Web\Form\Validator\TimeFormatValidator; -class TimeFormatValidatorTest extends PHPUnit_Framework_TestCase +class TimeFormatValidatorTest extends BaseTestCase { public function testValidateCorrectInput() { diff --git a/test/php/library/Icinga/Web/Form/Validator/WritablePathValidatorTest.php b/test/php/library/Icinga/Web/Form/Validator/WritablePathValidatorTest.php index 3a91dc0d9..b9e8c2ae7 100644 --- a/test/php/library/Icinga/Web/Form/Validator/WritablePathValidatorTest.php +++ b/test/php/library/Icinga/Web/Form/Validator/WritablePathValidatorTest.php @@ -1,38 +1,13 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web\Form\Validator; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Icinga\Web\Form\Validator\WritablePathValidator; -class WritablePathValidatorTest extends PHPUnit_Framework_TestCase +class WritablePathValidatorTest extends BaseTestCase { public function testValidateInputWithWritablePath() { diff --git a/test/php/library/Icinga/Web/FormTest.php b/test/php/library/Icinga/Web/FormTest.php index 8628550e5..d73dd0ef3 100644 --- a/test/php/library/Icinga/Web/FormTest.php +++ b/test/php/library/Icinga/Web/FormTest.php @@ -1,9 +1,11 @@ build(); $tabs = $builder->getTabs(); @@ -46,15 +50,15 @@ class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase public function testTabCreation1() { $widget = new Tabs(); - $builder = new Hook\Configuration\ConfigurationTabBuilder($widget); + $builder = new ConfigurationTabBuilder($widget); $tab1 = new ConfigurationTab('test1', '/test1', 'TEST1'); $tab2 = new ConfigurationTab('test2', '/test2', 'TEST2'); $tab3 = new ConfigurationTab('test3', '/test3', 'TEST3'); - Hook::registerObject(Hook\Configuration\ConfigurationTabBuilder::HOOK_NAMESPACE, 'test1', $tab1); - Hook::registerObject(Hook\Configuration\ConfigurationTabBuilder::HOOK_NAMESPACE, 'test2', $tab2); - Hook::registerObject(Hook\Configuration\ConfigurationTabBuilder::HOOK_NAMESPACE, 'test3', $tab3); + Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test1', $tab1); + Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test2', $tab2); + Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test3', $tab3); $builder->build(); @@ -68,10 +72,10 @@ class ConfigurationTabBuilderTest extends \PHPUnit_Framework_TestCase public function testTabCreation2() { $widget = new Tabs(); - $builder = new Hook\Configuration\ConfigurationTabBuilder($widget); + $builder = new ConfigurationTabBuilder($widget); $tab = new \stdClass(); - Hook::registerObject(Hook\Configuration\ConfigurationTabBuilder::HOOK_NAMESPACE, 'misc', $tab); + Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'misc', $tab); $builder->build(); $this->assertCount(5, $builder->getTabs()); diff --git a/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php b/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php index ae10ed13e..6f9fdaeb1 100644 --- a/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php +++ b/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php @@ -1,10 +1,13 @@ test = $test; } - /** - * @return mixed - */ public function getTest() { return $this->test; @@ -50,7 +47,7 @@ class ObjectHookImplementation } } -class HookTest extends \PHPUnit_Framework_TestCase +class HookTest extends BaseTestCase { protected function setUp() { @@ -64,11 +61,6 @@ class HookTest extends \PHPUnit_Framework_TestCase Hook::clean(); } - /** - * Test for Hook::Has() - * Note: This method is static! - * - **/ public function testHas() { $this->assertFalse(Hook::has("a")); @@ -79,11 +71,6 @@ class HookTest extends \PHPUnit_Framework_TestCase $this->assertTrue(Hook::has("a","b")); } - /** - * Test for Hook::CreateInstance() - * Note: This method is static! - * - **/ public function testCreateInstance() { Hook::$BASE_NS = "Tests\\Icinga\\Web\\"; @@ -92,12 +79,6 @@ class HookTest extends \PHPUnit_Framework_TestCase Hook::clean(); } - /** - * Test for Hook::CreateInstance() - * Note: This method is static! - * - * - **/ public function testCreateInvalidInstance1() { $this->setExpectedException('\Icinga\Exception\ProgrammingError'); @@ -122,11 +103,6 @@ class HookTest extends \PHPUnit_Framework_TestCase $this->assertNull($test); } - /** - * Test for Hook::All() - * Note: This method is static! - * - **/ public function testAll() { Hook::$BASE_NS = "Tests\\Icinga\\Web\\"; @@ -137,14 +113,8 @@ class HookTest extends \PHPUnit_Framework_TestCase foreach(Hook::all("Base") as $instance) { $this->assertInstanceOf("Tests\\Icinga\\Web\\TestHookImplementation",$instance); } - } - /** - * Test for Hook::First() - * Note: This method is static! - * - **/ public function testFirst() { Hook::$BASE_NS = "Tests\\Icinga\\Web\\"; diff --git a/test/php/library/Icinga/Web/NotificationTest.php b/test/php/library/Icinga/Web/NotificationTest.php index e70ef180c..edcad2c27 100644 --- a/test/php/library/Icinga/Web/NotificationTest.php +++ b/test/php/library/Icinga/Web/NotificationTest.php @@ -1,11 +1,15 @@ loggerPath = "/tmp/icinga2-web-notify-test"; $this->dropLog(); @@ -34,8 +38,6 @@ class NotificationTest extends \PHPUnit_Framework_TestCase )); $this->logger = new Logger($logConfig); - - // $this->notification = Notification::getInstance(); } protected function dropLog() diff --git a/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php b/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php index 8653a0b41..c7d8da04e 100644 --- a/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php +++ b/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php @@ -1,14 +1,16 @@ cacheDir); } - $statusdatFile = dirname(__FILE__) . '/../../../../../res/status/icinga.status.dat'; - $cacheFile = dirname(__FILE__) . '/../../../../../res/status/icinga.objects.cache'; + $statusdatFile = BaseTestCase::$testDir . '/res/status/icinga.status.dat'; + $cacheFile = BaseTestCase::$testDir . '/res/status/icinga.objects.cache'; $this->backendConfig = new Zend_Config( array( diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index 77823e8e5..cbe9974dc 100644 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -1,4 +1,6 @@ cacheDir); } - $statusdatFile = dirname(__FILE__). '/../../../../../res/status/icinga.status.dat'; - $cacheFile = dirname(__FILE__). '/../../../../../res/status/icinga.objects.cache'; + $statusdatFile = BaseTestCase::$testDir . '/res/status/icinga.status.dat'; + $cacheFile = BaseTestCase::$testDir . '/res/status/icinga.objects.cache'; $this->backendConfig = new Zend_Config( array( diff --git a/test/php/library/Icinga/Web/RequestMock.php b/test/php/library/Icinga/Web/RequestMock.php index 938bc4fd0..4cdce4e4c 100644 --- a/test/php/library/Icinga/Web/RequestMock.php +++ b/test/php/library/Icinga/Web/RequestMock.php @@ -1,38 +1,11 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web; /** - * Request mock that implements all methods required by the - * Url class - * + * Request mock that implements all methods required by the Url class */ class RequestMock { diff --git a/test/php/library/Icinga/Web/UrlTest.php b/test/php/library/Icinga/Web/UrlTest.php index 646545143..a15b975fd 100644 --- a/test/php/library/Icinga/Web/UrlTest.php +++ b/test/php/library/Icinga/Web/UrlTest.php @@ -1,45 +1,61 @@ assertEquals('/my/test/url.html', $url->getPath(), 'Assert the parsed url path to be equal to the input path'); - $this->assertEquals($url->getPath(), '/'.$url->getRelativeUrl(), 'Assert the path of an url without query to be equal the relative path'); + $this->assertEquals( + '/my/test/url.html', + $url->getPath(), + 'Assert the parsed url path to be equal to the input path' + ); + $this->assertEquals( + $url->getPath(), + '/' . $url->getRelativeUrl(), + 'Assert the path of an url without query to be equal the relative path' + ); } /** * Tests whether a simple Url without query parameters and with baseUrl is correctly parsed and returns correct Urls - * */ function testFromUrlWithBasePath() { $url = Url::fromPath('my/test/url.html', array(), new RequestMock()); $url->setBaseUrl('the/path/to'); - $this->assertEquals('/the/path/to/my/test/url.html', $url->getAbsoluteUrl(), 'Assert the url path to be the base path with the relative path'); + $this->assertEquals( + '/the/path/to/my/test/url.html', + $url->getAbsoluteUrl(), + 'Assert the url path to be the base path with the relative path' + ); } /** * Tests whether query parameters in Urls are correctly recognized and decoded - * */ function testFromUrlWithKeyValueQuery() { $url = Url::fromPath('/my/test/url.html?param1=%25arg1¶m2=arg2', array(), new RequestMock()); - $this->assertEquals('/my/test/url.html', $url->getPath(), 'Assert the parsed url path to be equal to the input path'); + $this->assertEquals( + '/my/test/url.html', + $url->getPath(), + 'Assert the parsed url path to be equal to the input path' + ); $this->assertEquals( array( 'param1' => '%arg1', @@ -52,7 +68,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Tests whether unnamed query parameters in Urls are correctly recognized and decoded - * */ function testFromUrlWithArrayInQuery() { @@ -68,11 +83,14 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Tests whether named query parameters in Urls are correctly recognized and decoded - * */ function testFromUrlWithAssociativeArrayInQuery() { - $url = Url::fromPath('/my/test/url.html?param[value]=%25val1¶m[value2]=%40val2', array(), new RequestMock()); + $url = Url::fromPath( + '/my/test/url.html?param[value]=%25val1¶m[value2]=%40val2', + array(), + new RequestMock() + ); $this->assertEquals( array( 'param' => array( @@ -87,7 +105,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Tests whether simple query parameters can be correctly added on an existing query and ends up in correct Urls - * */ function testAddQueryParameterToUrlWithoutQuery() { @@ -108,9 +125,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase } /** - * Test whether parameters are correctly added to existing query parameters and existing ones are correctly overwritten - * if they have the same key - * + * Test whether parameters are correctly added to existing query parameters + * and existing ones are correctly overwritten if they have the same key */ function testOverwritePartialQuery() { @@ -132,7 +148,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test whether array parameters are correctly added to an existing Url and end up in correct Urls - * */ function testSetQueryWithArrayParameter() { @@ -157,7 +172,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test whether Urls from the request are correctly parsed when no query is given - * */ function testUrlFromRequestWithoutQuery() { @@ -175,7 +189,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test whether Urls from the request are correctly parsed when a query is given - * */ function testUrlFromRequestWithQuery() { @@ -198,7 +211,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test the @see Url::getParam($name, $default) function - * */ function testGetParameterByName() { @@ -222,7 +234,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test the Url::remove function with a single key passed - * */ function testRemoveSingleParameter() { @@ -242,7 +253,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test the Url::remove function with an array of keys passed - * */ function testRemoveMultipleParameters() { @@ -267,7 +277,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test the Url::without call and whether it returns a copy instead of working on the called object - * */ function testWithoutCall() { @@ -309,11 +318,14 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Test whether toString is the same as getAbsoluteUrl - * */ function testToString() { $url = Url::fromPath('/my/test/url.html?param=val¶m2=val2¶m3=val3', array(), new RequestMock()); - $this->assertEquals($url->getAbsoluteUrl(), (string) $url, "Asserting whether toString returns the absolute Url"); + $this->assertEquals( + $url->getAbsoluteUrl(), + (string) $url, + "Asserting whether toString returns the absolute Url" + ); } } diff --git a/test/php/library/Icinga/Web/ViewMock.php b/test/php/library/Icinga/Web/ViewMock.php index 896cb6a7c..80806a7a7 100644 --- a/test/php/library/Icinga/Web/ViewMock.php +++ b/test/php/library/Icinga/Web/ViewMock.php @@ -1,49 +1,14 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web; use \Zend_View_Abstract; -/** - * ViewMock that does absolutely nothing - * - */ class ViewMock extends Zend_View_Abstract { - /** - * No operation is performed here - */ protected function _run() { } } - -// @codingStandardsIgnoreEnd diff --git a/test/php/library/Icinga/Web/Widget/TabTest.php b/test/php/library/Icinga/Web/Widget/TabTest.php index d156bb271..5acc99eab 100644 --- a/test/php/library/Icinga/Web/Widget/TabTest.php +++ b/test/php/library/Icinga/Web/Widget/TabTest.php @@ -1,35 +1,10 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web\Widget; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Tests\Icinga\Web\RequestMock; use Tests\Icinga\Web\ViewMock; use Icinga\Web\Widget\Tab; @@ -38,7 +13,7 @@ use Icinga\Web\Url; /** * Test creation and rendering of tabs */ -class TabTest extends PHPUnit_Framework_TestCase +class TabTest extends BaseTestCase { /** * Test whether rendering a tab without URL is done correctly diff --git a/test/php/library/Icinga/Web/Widget/TabsTest.php b/test/php/library/Icinga/Web/Widget/TabsTest.php index e070f0e7e..35181257e 100644 --- a/test/php/library/Icinga/Web/Widget/TabsTest.php +++ b/test/php/library/Icinga/Web/Widget/TabsTest.php @@ -1,42 +1,17 @@ - * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 - * @author Icinga Development Team - * - */ // {{{ICINGA_LICENSE_HEADER}}} namespace Tests\Icinga\Web\Widget; -use \PHPUnit_Framework_TestCase; +use Icinga\Test\BaseTestCase; use Tests\Icinga\Web\ViewMock; use Icinga\Web\Widget\Tabs; /** * Test rendering of tabs and corretct tab management */ -class TabsTest extends PHPUnit_Framework_TestCase +class TabsTest extends BaseTestCase { /** * Test adding tabs and asserting for correct count diff --git a/test/php/regression/Bug4102Test.php b/test/php/regression/Bug4102Test.php index ea4cedf80..ce5ea2290 100644 --- a/test/php/regression/Bug4102Test.php +++ b/test/php/regression/Bug4102Test.php @@ -4,6 +4,8 @@ namespace Tests\Icinga\Regression; +use Icinga\Test\BaseTestCase; + /** * Class Bug4102 * @@ -11,7 +13,7 @@ namespace Tests\Icinga\Regression; * * @see https://dev.icinga.org/issues/4102 */ -class Bug4102Test extends \PHPUnit_Framework_TestCase +class Bug4102Test extends BaseTestCase { /** * Test class name to match definition