From 91675bac5040f06f9297876fe37725ce222a0bad Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 9 Apr 2014 14:18:14 +0200 Subject: [PATCH] Remove require instructions from all tests and fix namespaces refs #4639 --- .../controllers/IndexControllerTest.php | 2 - .../forms/Config/AuthenticationFormTest.php | 4 +- .../forms/Config/GeneralFormTest.php | 2 +- .../forms/Config/LoggingFormTest.php | 2 +- .../forms/Preference/GeneralFormTest.php | 9 ++- test/php/bootstrap.php | 5 ++ .../library/Icinga/Application/ConfigTest.php | 3 - .../library/Icinga/Application/LoaderTest.php | 9 --- .../library/Icinga/Application/LoggerTest.php | 12 +--- .../Icinga/Application/Modules/Manager.php | 7 -- .../library/Icinga/Application/ZendDbMock.php | 1 - .../Authentication/DbUserBackendTest.php | 29 +------- .../Authentication/LdapUserBackendTest.php | 23 +------ .../Icinga/Authentication/ManagerTest.php | 3 +- .../library/Icinga/Chart/GraphChartTest.php | 5 +- .../php/library/Icinga/Chart/PieChartTest.php | 3 +- .../Icinga/Config/PreservingIniWriterTest.php | 9 +-- test/php/library/Icinga/Filter/DomainTest.php | 13 ---- test/php/library/Icinga/Filter/FilterTest.php | 19 +----- .../Icinga/Filter/QueryHandlerTest.php | 11 ---- .../Icinga/Filter/Type/BooleanFilterTest.php | 14 ---- .../Icinga/Filter/Type/TextSearchTest.php | 10 --- .../Filter/Type/TimeRangeSpecifierTest.php | 9 --- test/php/library/Icinga/LibraryLoader.php | 54 --------------- .../Protocol/Commandpipe/CommandPipeTest.php | 12 ++-- .../Icinga/Protocol/Ldap/QueryTest.php | 18 ++--- .../Component/StatusdatComponentTest.php | 5 +- .../Statusdat/Exceptions/ParsingException.php | 1 + .../Icinga/Protocol/Statusdat/ParserTest.php | 7 -- .../Statusdat/Query/ExpressionTest.php | 19 +----- .../Protocol/Statusdat/Query/GroupTest.php | 28 +++----- .../Icinga/Protocol/Statusdat/QueryTest.php | 30 +++------ .../Icinga/Protocol/Statusdat/ReaderMock.php | 2 +- .../Icinga/Protocol/Statusdat/ReaderTest.php | 7 +- .../Statusdat/RuntimeStateContainerTest.php | 7 +- .../library/Icinga/Session/PhpSessionTest.php | 16 +---- .../Icinga/Session/SessionNamespaceTest.php | 11 +--- .../Icinga/Test/BaseTestCaseDbTest.php | 6 -- .../Web/Form/Element/DateTimePickerTest.php | 18 ++--- .../Validator/DateFormatValidatorTest.php | 7 +- .../Validator/TimeFormatValidatorTest.php | 8 +-- .../Validator/WritablePathValidatorTest.php | 9 +-- test/php/library/Icinga/Web/FormTest.php | 7 -- .../ConfigurationTabBuilderTest.php | 10 --- .../Configuration/ConfigurationTabTest.php | 4 -- test/php/library/Icinga/Web/HookTest.php | 13 +--- .../library/Icinga/Web/NotificationTest.php | 12 ---- .../Paginator/Adapter/QueryAdapterTest.php | 9 ++- .../ScrollingStyle/SlidingWithBorderTest.php | 19 ++---- test/php/library/Icinga/Web/UrlTest.php | 5 -- test/php/library/Icinga/Web/ViewMock.php | 1 - .../php/library/Icinga/Web/Widget/TabTest.php | 23 +------ .../library/Icinga/Web/Widget/TabsTest.php | 21 +----- test/php/regression/Bug4102Test.php | 7 +- .../regression/LoginMaskBroken4459Test.php | 66 ------------------- 55 files changed, 94 insertions(+), 572 deletions(-) delete mode 100644 test/php/library/Icinga/LibraryLoader.php delete mode 100644 test/php/regression/LoginMaskBroken4459Test.php diff --git a/test/php/application/controllers/IndexControllerTest.php b/test/php/application/controllers/IndexControllerTest.php index 2d14584f3..06550063c 100644 --- a/test/php/application/controllers/IndexControllerTest.php +++ b/test/php/application/controllers/IndexControllerTest.php @@ -2,8 +2,6 @@ namespace Tests\Application\Controller; -use Icinga\Application\Icinga; - class IndexControllerTest extends \Zend_Test_PHPUnit_ControllerTestCase { private $applicationPath; diff --git a/test/php/application/forms/Config/AuthenticationFormTest.php b/test/php/application/forms/Config/AuthenticationFormTest.php index 43ae699d0..7115efb03 100644 --- a/test/php/application/forms/Config/AuthenticationFormTest.php +++ b/test/php/application/forms/Config/AuthenticationFormTest.php @@ -27,13 +27,13 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Test\Form\Config; +namespace Tests\Icinga\Form\Config; use Icinga\Test\BaseTestCase; use \Zend_Config; use \Icinga\Web\Url; -use \Tests\Icinga\Web\RequestMock; +use Tests\Icinga\Web\RequestMock; /** * Test for the authentication provider form diff --git a/test/php/application/forms/Config/GeneralFormTest.php b/test/php/application/forms/Config/GeneralFormTest.php index 3f0dbb2f0..276d2ee7b 100644 --- a/test/php/application/forms/Config/GeneralFormTest.php +++ b/test/php/application/forms/Config/GeneralFormTest.php @@ -27,7 +27,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Test\Form\Config; +namespace Tests\Icinga\Form\Config; use \DateTimeZone; use \DOMDocument; diff --git a/test/php/application/forms/Config/LoggingFormTest.php b/test/php/application/forms/Config/LoggingFormTest.php index b82ada82b..50632afa2 100644 --- a/test/php/application/forms/Config/LoggingFormTest.php +++ b/test/php/application/forms/Config/LoggingFormTest.php @@ -27,7 +27,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Test\Form\Config; +namespace Tests\Icinga\Form\Config; use \Zend_Config; Use Icinga\Test\BaseTestCase; diff --git a/test/php/application/forms/Preference/GeneralFormTest.php b/test/php/application/forms/Preference/GeneralFormTest.php index f931f18cf..b66cb6480 100644 --- a/test/php/application/forms/Preference/GeneralFormTest.php +++ b/test/php/application/forms/Preference/GeneralFormTest.php @@ -27,14 +27,13 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Test\Form\Preference; - -use Icinga\Test\BaseTestCase; +namespace Tests\Icinga\Form\Preference; use \DateTimeZone; -use \Icinga\User\Preferences; use \Zend_View_Helper_DateFormat; -use \Icinga\Util\DateTimeFactory; +use Icinga\Test\BaseTestCase; +use Icinga\User\Preferences; +use Icinga\Util\DateTimeFactory; /** * Test for general form, mainly testing enable/disable behaviour diff --git a/test/php/bootstrap.php b/test/php/bootstrap.php index 413052450..e43d71afc 100644 --- a/test/php/bootstrap.php +++ b/test/php/bootstrap.php @@ -3,12 +3,16 @@ $applicationPath = realpath(dirname(__FILE__) . '/../../application/'); $modulePath = realpath(dirname(__FILE__) . '/../../modules/'); $libraryPath = realpath(dirname(__FILE__) . '/../../library/'); +$testLibraryPath = realpath(dirname(__FILE__) . '/library/'); $configPath = realpath($libraryPath . '/../config'); // Is usually done in the application's bootstrap and is used by some of our internals if (!defined('ICINGA_APPDIR')) { define('ICINGA_APPDIR', $applicationPath); } +if (!defined('ICINGA_LIBDIR')) { + define('ICINGA_LIBDIR', $libraryPath); +} // This is needed to get the Zend Plugin loader working set_include_path(implode(PATH_SEPARATOR, array($libraryPath, get_include_path()))); @@ -16,6 +20,7 @@ set_include_path(implode(PATH_SEPARATOR, array($libraryPath, get_include_path()) require_once($libraryPath . '/Icinga/Application/Loader.php'); $loader = new Icinga\Application\Loader(); +$loader->registerNamespace('Tests', $testLibraryPath); $loader->registerNamespace('Icinga', $libraryPath . '/Icinga'); $loader->registerNamespace('Icinga\\Form', $applicationPath . '/forms'); diff --git a/test/php/library/Icinga/Application/ConfigTest.php b/test/php/library/Icinga/Application/ConfigTest.php index 98a83fdaa..61264b131 100644 --- a/test/php/library/Icinga/Application/ConfigTest.php +++ b/test/php/library/Icinga/Application/ConfigTest.php @@ -29,9 +29,6 @@ namespace Tests\Icinga\Application; -require_once 'Zend/Config/Ini.php'; -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Application/Config.php'); - use \Icinga\Application\Config as IcingaConfig; class ConfigTest extends \PHPUnit_Framework_TestCase diff --git a/test/php/library/Icinga/Application/LoaderTest.php b/test/php/library/Icinga/Application/LoaderTest.php index 4c3d101ad..9bf220e32 100644 --- a/test/php/library/Icinga/Application/LoaderTest.php +++ b/test/php/library/Icinga/Application/LoaderTest.php @@ -2,17 +2,8 @@ namespace Tests\Icinga\Application; -require_once __DIR__. '/../../../../../library/Icinga/Exception/ProgrammingError.php'; -require_once __DIR__. '/../../../../../library/Icinga/Application/Loader.php'; - use Icinga\Application\Loader; -/** -* -* Test class for Loader -* Created Thu, 07 Feb 2013 10:07:13 +0000 -* -**/ class LoaderTest extends \PHPUnit_Framework_TestCase { private static $classFile = 'test/My/Library/TestStruct.php'; diff --git a/test/php/library/Icinga/Application/LoggerTest.php b/test/php/library/Icinga/Application/LoggerTest.php index 32e8d3980..42cfa636d 100644 --- a/test/php/library/Icinga/Application/LoggerTest.php +++ b/test/php/library/Icinga/Application/LoggerTest.php @@ -27,19 +27,11 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -// @codingStandardsIgnoreEnd +namespace Tests\Icinga\Application; -use Icinga\Test\BaseTestCase; - -// @codingStandardsIgnoreStart -require_once BaseTestCase::$libDir . '/Logger/Logger.php'; -require_once BaseTestCase::$libDir . '/Logger/LogWriter.php'; -require_once BaseTestCase::$libDir . '/Logger/Writer/StreamWriter.php'; -// @codingStandardsIgnoreEnd use \Zend_Config; +use Icinga\Test\BaseTestCase; use Icinga\Logger\Logger; 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 116b1d1b5..bb7e5e2ad 100644 --- a/test/php/library/Icinga/Application/Modules/Manager.php +++ b/test/php/library/Icinga/Application/Modules/Manager.php @@ -2,16 +2,10 @@ namespace Tests\Icinga\Application\Module\Manager; -require_once("../../library/Icinga/Application/Modules/Manager.php"); -require_once("../../library/Icinga/Exception/ProgrammingError.php"); -require_once("../../library/Icinga/Exception/ConfigurationError.php"); -require_once("../../library/Icinga/Exception/SystemPermissionException.php"); - use Icinga\Application\Modules\Manager as ModuleManager; class ModuleMock { - public $name = ""; public $dir = ""; @@ -105,6 +99,5 @@ class ManagerTest extends \PHPUnit_Framework_TestCase { $moduleDir = self::MODULE_TARGET; exec("rm -r $moduleDir/enabledModules"); - } } diff --git a/test/php/library/Icinga/Application/ZendDbMock.php b/test/php/library/Icinga/Application/ZendDbMock.php index 2579b83e5..281119296 100644 --- a/test/php/library/Icinga/Application/ZendDbMock.php +++ b/test/php/library/Icinga/Application/ZendDbMock.php @@ -34,7 +34,6 @@ namespace Tests\Icinga\Application; */ class ZendDbMock { - /** * The config that was used in the last call of the factory function * diff --git a/test/php/library/Icinga/Authentication/DbUserBackendTest.php b/test/php/library/Icinga/Authentication/DbUserBackendTest.php index 591cc129a..8132111d1 100644 --- a/test/php/library/Icinga/Authentication/DbUserBackendTest.php +++ b/test/php/library/Icinga/Authentication/DbUserBackendTest.php @@ -29,36 +29,11 @@ namespace Tests\Icinga\Authentication; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -// @codingStandardsIgnoreEnd - -use \Icinga\Test\BaseTestCase; - -// @codingStandardsIgnoreStart -require_once 'Zend/Config.php'; -require_once 'Zend/Config/Ini.php'; -require_once 'Zend/Db/Adapter/Abstract.php'; -require_once 'Zend/Db.php'; -require_once 'Zend/Log.php'; -require_once BaseTestCase::$libDir . '/Exception/ProgrammingError.php'; -require_once BaseTestCase::$libDir . '/Util/ConfigAwareFactory.php'; -require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php'; -require_once BaseTestCase::$libDir . '/Protocol/Ldap/Exception.php'; -require_once BaseTestCase::$libDir . '/Application/Config.php'; -require_once BaseTestCase::$libDir . '/Authentication/Credential.php'; -require_once BaseTestCase::$libDir . '/Authentication/Backend/DbUserBackend.php'; -require_once BaseTestCase::$libDir . '/User.php'; -require_once BaseTestCase::$libDir . '/Application/Logger.php'; -// @codingStandardsIgnoreEnd - use \PDO; use \Zend_Db_Adapter_Pdo_Abstract; use \Zend_Config; -use \Icinga\Authentication\Backend\DbUserBackend; -use \Icinga\Authentication\Credential; -use \Icinga\User; -use \Icinga\Application\Config; +use Icinga\Test\BaseTestCase; +use Icinga\Authentication\Backend\DbUserBackend; /** * Test Class fpr DbUserBackend diff --git a/test/php/library/Icinga/Authentication/LdapUserBackendTest.php b/test/php/library/Icinga/Authentication/LdapUserBackendTest.php index b0c22edc7..29a4d3767 100644 --- a/test/php/library/Icinga/Authentication/LdapUserBackendTest.php +++ b/test/php/library/Icinga/Authentication/LdapUserBackendTest.php @@ -29,33 +29,12 @@ namespace Tests\Icinga\Authentication; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -// @codingStandardsIgnoreEnd - -use Icinga\Authentication\Credential; -use \Icinga\Test\BaseTestCase; - -// @codingStandardsIgnoreStart -require_once 'Zend/Config.php'; -require_once BaseTestCase::$libDir . '/Protocol/Ldap/Connection.php'; -require_once BaseTestCase::$libDir . '/Protocol/Ldap/Query.php'; -require_once BaseTestCase::$libDir . '/Authentication/Credential.php'; -require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php'; -require_once BaseTestCase::$libDir . '/Authentication/Backend/LdapUserBackend.php'; -// @codingStandardsIgnoreEnd - use \Exception; use \Zend_Config; +use Icinga\Test\BaseTestCase; use Icinga\Authentication\Backend\LdapUserBackend; use Icinga\Protocol\Ldap\Connection as LdapConnection; -/** -* -* Test class for Ldapuserbackend -* Created Mon, 10 Jun 2013 07:54:34 +0000 -* -**/ class LdapUserBackendTest extends BaseTestCase { // Change this according to your ldap test server diff --git a/test/php/library/Icinga/Authentication/ManagerTest.php b/test/php/library/Icinga/Authentication/ManagerTest.php index 94897d187..ce5e090a6 100644 --- a/test/php/library/Icinga/Authentication/ManagerTest.php +++ b/test/php/library/Icinga/Authentication/ManagerTest.php @@ -27,7 +27,7 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Tests\Authentication; +namespace Tests\Icinga\Authentication; use Icinga\Test\BaseTestCase; @@ -35,7 +35,6 @@ use \Zend_Config; use Icinga\Web\Session; use Icinga\Authentication\Manager as AuthManager; use Icinga\Authentication\Credential; -use Icinga\Exception\ConfigurationError; use Icinga\Test\Authentication\ErrorProneBackendMock; use Icinga\Test\Authentication\SessionMock; use Icinga\Test\Authentication\BackendMock; diff --git a/test/php/library/Icinga/Chart/GraphChartTest.php b/test/php/library/Icinga/Chart/GraphChartTest.php index c33261d88..72418c402 100644 --- a/test/php/library/Icinga/Chart/GraphChartTest.php +++ b/test/php/library/Icinga/Chart/GraphChartTest.php @@ -29,12 +29,11 @@ namespace Tests\Icinga\Chart; -use DOMXPath; -use DOMDocument; +use \DOMXPath; +use \DOMDocument; use Icinga\Chart\GridChart; use Icinga\Test\BaseTestCase; -use Test\Icinga\LibraryLoader; class GraphChartTest extends BaseTestCase { diff --git a/test/php/library/Icinga/Chart/PieChartTest.php b/test/php/library/Icinga/Chart/PieChartTest.php index 3bdbaa1b1..bf92eae25 100644 --- a/test/php/library/Icinga/Chart/PieChartTest.php +++ b/test/php/library/Icinga/Chart/PieChartTest.php @@ -27,12 +27,11 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Tests\Chart; +namespace Tests\Icinga\Chart; use \DOMXPath; use \DOMDocument; -use Icinga\Chart\GridChart; 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 fe833edf7..f57066275 100644 --- a/test/php/library/Icinga/Config/PreservingIniWriterTest.php +++ b/test/php/library/Icinga/Config/PreservingIniWriterTest.php @@ -1,5 +1,4 @@ assertEquals($node->right, 'my host', 'Assert a domain to insert the value as the right side of a treenode'); $this->assertEquals($node->operator, Node::OPERATOR_EQUALS, 'Assert the correct operator to be set in a single query'); } - } \ No newline at end of file diff --git a/test/php/library/Icinga/Filter/FilterTest.php b/test/php/library/Icinga/Filter/FilterTest.php index 57cc1f22a..ad3fbbaee 100644 --- a/test/php/library/Icinga/Filter/FilterTest.php +++ b/test/php/library/Icinga/Filter/FilterTest.php @@ -27,27 +27,13 @@ */ // {{{ICINGA_LICENSE_HEADER}}} - namespace Tests\Icinga\Filter; -use Icinga\Test\BaseTestCase; use Icinga\Filter\FilterAttribute; use Icinga\Filter\Filter; use Icinga\Filter\Type\TextFilter; use Icinga\Filter\Query\Node; - -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/QueryProposer.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Filter.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/FilterAttribute.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Domain.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Query/Node.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Query/Tree.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Type/FilterType.php'); -require_once realpath(BaseTestCase::$libDir . '/Filter/Type/TextFilter.php'); - -// @codingStandardsIgnoreEnd +use Icinga\Test\BaseTestCase; class FilterTest extends BaseTestCase { @@ -77,7 +63,6 @@ class FilterTest extends BaseTestCase $searchEngine->getProposalsForQuery('Host name Is test and Hostname contains'), 'Assert only proposals for the last query part being made' ); - } public function testSingleQueryTreeCreation() @@ -245,7 +230,6 @@ class FilterTest extends BaseTestCase ->setHandledAttributes('attr5') ); - $query = 'attr1 is not \'Hans wurst\'' . ' or attr2 contains something ' . ' and attr3 starts with bla' @@ -298,5 +282,4 @@ class FilterTest extends BaseTestCase 'Assert the root->right->right->type node to be an OPERATOR (query :"' . $query . '")' ); } - } \ No newline at end of file diff --git a/test/php/library/Icinga/Filter/QueryHandlerTest.php b/test/php/library/Icinga/Filter/QueryHandlerTest.php index 6d4cd04a5..e88296388 100644 --- a/test/php/library/Icinga/Filter/QueryHandlerTest.php +++ b/test/php/library/Icinga/Filter/QueryHandlerTest.php @@ -27,7 +27,6 @@ */ // {{{ICINGA_LICENSE_HEADER}}} - namespace Tests\Icinga\Filter; use Icinga\Filter\Query\Node; @@ -35,14 +34,6 @@ use Icinga\Filter\FilterAttribute; use Icinga\Filter\Type\FilterType; use Icinga\Test\BaseTestCase; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Query/Node.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/QueryProposer.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Domain.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/FilterAttribute.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/FilterType.php'); - class TypeMock extends FilterType { public function isValidQuery($query) @@ -119,7 +110,6 @@ class QueryHandlerTest extends BaseTestCase public function testOperatorProposal() { - $handler = new FilterAttribute(new TypeMock()); $handler->setField('current_status') ->setHandledAttributes('status', 'state', 'current state'); @@ -138,5 +128,4 @@ class QueryHandlerTest extends BaseTestCase $node = $handler->convertToTreeNode('status is not \’some kind of magic\''); $this->assertEquals($node->left, 'current_status', 'Assert status to be set to the field'); } - } \ No newline at end of file diff --git a/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php b/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php index 5ebdf3b84..c74c63e6d 100644 --- a/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php +++ b/test/php/library/Icinga/Filter/Type/BooleanFilterTest.php @@ -27,26 +27,14 @@ */ // {{{ICINGA_LICENSE_HEADER}}} - namespace Tests\Icinga\Filter; use Icinga\Filter\Type\BooleanFilter; -use Icinga\Filter\Type\TimeRangeSpecifier; use Icinga\Filter\Query\Node; use Icinga\Test\BaseTestCase; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../../library/Icinga/Test/BaseTestCase.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Query/Node.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/QueryProposer.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/FilterType.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/BooleanFilter.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/TimeRangeSpecifier.php'); -// @codingStandardsIgnoreEnd - class BooleanFilterTest extends BaseTestCase { - public function testOperatorProposal() { $filter = new BooleanFilter(array()); @@ -124,7 +112,6 @@ class BooleanFilterTest extends BaseTestCase $this->assertEquals(Node::OPERATOR_EQUALS, $node->operator, 'Assert the operator to be equals'); $this->assertEquals(1, $node->right[0], 'Assert the value to be 1'); - $node = $filter->createTreeNode('is not with problem', 'host_status'); $this->assertEquals('host_problem', $node->left, 'Assert the left part of the node to be host_problem'); $this->assertEquals(Node::OPERATOR_EQUALS, $node->operator, 'Assert the operator to be equals'); @@ -149,6 +136,5 @@ class BooleanFilterTest extends BaseTestCase $this->assertEquals('host_problem', $node->right->left, 'Assert the right part of the node to be host_problem'); $this->assertEquals(Node::OPERATOR_EQUALS, $node->right->operator, 'Assert the operator to be equals'); $this->assertEquals(1, $node->right->right[0], 'Assert the value to be 1'); - } } \ No newline at end of file diff --git a/test/php/library/Icinga/Filter/Type/TextSearchTest.php b/test/php/library/Icinga/Filter/Type/TextSearchTest.php index 927f60bf5..fc5d3dab5 100644 --- a/test/php/library/Icinga/Filter/Type/TextSearchTest.php +++ b/test/php/library/Icinga/Filter/Type/TextSearchTest.php @@ -33,14 +33,6 @@ use Icinga\Filter\Type\TextFilter; use Icinga\Filter\Query\Node; use Icinga\Test\BaseTestCase; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../../library/Icinga/Test/BaseTestCase.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Query/Node.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/QueryProposer.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/FilterType.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/TextFilter.php'); -// @codingStandardsIgnoreEnd - class TextFilterTest extends BaseTestCase { public function testOperatorProposal() @@ -65,13 +57,11 @@ class TextFilterTest extends BaseTestCase ); } - public function testGetOperatorAndValueFromQuery() { $textFilter = new TextFilter(); list($operator, $value) = $textFilter->getOperatorAndValueFromQuery('is not \'something\''); $this->assertEquals(Node::OPERATOR_EQUALS_NOT, $operator, 'Asserting text operators to be split via TextFilter'); $this->assertEquals('something', $value, 'Asserting quoted values to be recognized in TextFilter'); - } } \ No newline at end of file diff --git a/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php b/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php index 08319e3e4..5312ad14a 100644 --- a/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php +++ b/test/php/library/Icinga/Filter/Type/TimeRangeSpecifierTest.php @@ -30,17 +30,8 @@ namespace Tests\Icinga\Filter; use Icinga\Filter\Type\TimeRangeSpecifier; -use Icinga\Filter\Query\Node; use Icinga\Test\BaseTestCase; -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../../library/Icinga/Test/BaseTestCase.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Query/Node.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/QueryProposer.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/FilterType.php'); -require_once realpath(BaseTestCase::$libDir .'/Filter/Type/TimeRangeSpecifier.php'); -// @codingStandardsIgnoreEnd - class TimeRangeSpecifierTest extends BaseTestCase { public function testIsValid() diff --git a/test/php/library/Icinga/LibraryLoader.php b/test/php/library/Icinga/LibraryLoader.php deleted file mode 100644 index 55c0a9202..000000000 --- a/test/php/library/Icinga/LibraryLoader.php +++ /dev/null @@ -1,54 +0,0 @@ - 'localhost', 'root_dn' => 'dc=example,dc=com', diff --git a/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php b/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php index 9435a02bb..bc4752016 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Component/StatusdatComponentTest.php @@ -2,7 +2,8 @@ namespace Tests\Icinga\Protocol\Statusdat; -use \Icinga\Protocol\Statusdat as SD; +use \Zend_Config; +use Icinga\Protocol\Statusdat\Reader; /** * This is a high level test for the whole statusdat component, i.e. all parts put together @@ -11,7 +12,7 @@ use \Icinga\Protocol\Statusdat as SD; class StatusdatComponentTest extends \PHPUnit_Framework_TestCase { public function getReader() { - $reader = new SD\Reader(new \Zend_Config(array( + $reader = new Reader(new Zend_Config(array( "status_file" => dirname(__FILE__)."/status.dat", "object_file" => dirname(__FILE__)."/objects.cache" )),null,true); diff --git a/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php b/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php index 392f979e2..8a206c1bc 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Exceptions/ParsingException.php @@ -1,4 +1,5 @@ "atest", @@ -118,7 +106,6 @@ class ExpressionTest extends \PHPUnit_Framework_TestCase $result = $expression->filter($testArray); $this->assertEquals(1, count($result)); - } public function testCountQuery() @@ -142,10 +129,6 @@ class ExpressionTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, count($result)); } - /** - * Test for Expression::Filter() - * - **/ public function testFilter() { $this->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 8f299952c..69298e080 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Query/GroupTest.php @@ -1,16 +1,11 @@ value = array_shift($value); $this->rawExpression = $expression; - } public function filter(array &$base, &$idx = null) @@ -38,8 +32,6 @@ class QueryExpressionMock implements Statusdat\Query\IQueryPart { // TODO: Implement setQuery() method. } - - } class GroupTest extends \PHPUnit_Framework_TestCase @@ -48,7 +40,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { $testQuery = new Statusdat\Query\Group(); $value = array(4); - $testQuery->fromString("numeric_val >= ?", $value, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock"); + $testQuery->fromString("numeric_val >= ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock"); $this->assertCount(1, $testQuery->getItems()); $this->assertCount(0, $value); @@ -57,14 +49,13 @@ class GroupTest extends \PHPUnit_Framework_TestCase $this->assertEquals("numeric_val >= ?", $expression->rawExpression); $this->assertEquals(4, $expression->value); - } public function testParsingSimpleAndCondition() { $testQuery = new Statusdat\Query\Group(); $value = array(4, 'hosta'); - $testQuery->fromString("numeric_val >= ? AND host_name = ?", $value, "Icinga\Tests\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()); @@ -83,7 +74,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { $testQuery = new Statusdat\Query\Group(); $value = array(4, 'hosta'); - $testQuery->fromString("numeric_val >= ? OR host_name = ?", $value, "Icinga\Tests\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()); @@ -102,7 +93,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { $testQuery = new Statusdat\Query\Group(); $value = array(4, 'service1', 'hosta'); - $testQuery->fromString("numeric_val >= ? AND (service_description = ? OR host_name = ?)", $value, "Icinga\Tests\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()); @@ -130,7 +121,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { $testQuery = new Statusdat\Query\Group(); $value = array(4, 'service1', 'hosta'); - $testQuery->fromString("numeric_val >= ? AND service_description = ? OR host_name = ?", $value, "Icinga\Tests\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()); @@ -165,7 +156,6 @@ class GroupTest extends \PHPUnit_Framework_TestCase $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))); - } public function testOrFilter() diff --git a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php index 573781ad2..35481f28b 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php @@ -1,22 +1,15 @@ getServiceTestReader(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $objects = $readerMock->getObjects(); $result = $query->select()->from("services")->getResult(); @@ -26,41 +19,38 @@ class QueryTest extends \PHPUnit_Framework_TestCase public function testSimpleHostSelect() { $readerMock = $this->getServiceTestReader(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $objects = $readerMock->getObjects(); $result = $query->from("hosts")->getResult(); $this->assertCount(count($objects["host"]), $result); - } public function testLimit() { $readerMock = $this->getServiceTestReader(); $objects = $readerMock->getObjects(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $result = $query->from("services")->limit(2)->getResult(); $this->assertCount(2, $result); - } public function testOffset() { $readerMock = $this->getServiceTestReader(); $objects = $readerMock->getObjects(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $result = $query->from("services")->limit(2, 4)->getResult(); $this->assertCount(2, $result); - } public function testGroupByColumn() { $readerMock = $this->getServiceTestReader(); $objects = $readerMock->getObjects(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $result = $query->from("services")->groupByColumns("numeric_val")->getResult(); $this->assertCount(3,$result); foreach($result as $value) { @@ -68,28 +58,24 @@ class QueryTest extends \PHPUnit_Framework_TestCase $this->assertTrue(isset($value->columns)); $this->assertEquals(2,$value->count); } - } public function testOrderedGroupByColumn() { $readerMock = $this->getServiceTestReader(); $objects = $readerMock->getObjects(); - $query = new Statusdat\Query($readerMock); + $query = new Query($readerMock); $result = $query->from("services")->order('numeric_val ASC')->groupByColumns("numeric_val")->getResult(); $this->assertCount(3,$result); foreach($result as $sstatus) { $this->assertTrue(isset($sstatus->count)); $this->assertTrue(isset($sstatus->columns)); $this->assertEquals(2, $sstatus->count); - } - } private function getServiceTestReader() { - require_once('ReaderMock.php'); $readerMock = new ReaderMock(array( "host" => array( "hosta" => (object) array( diff --git a/test/php/library/Icinga/Protocol/Statusdat/ReaderMock.php b/test/php/library/Icinga/Protocol/Statusdat/ReaderMock.php index eda67aa2d..7e9a6f03a 100644 --- a/test/php/library/Icinga/Protocol/Statusdat/ReaderMock.php +++ b/test/php/library/Icinga/Protocol/Statusdat/ReaderMock.php @@ -1,5 +1,5 @@ assertEquals("test host",$container->host_name); $this->assertEquals($container->test,"test123"); $this->assertEquals(0,$container->current_state); - } - } diff --git a/test/php/library/Icinga/Session/PhpSessionTest.php b/test/php/library/Icinga/Session/PhpSessionTest.php index 96ded3dc7..22bda1605 100644 --- a/test/php/library/Icinga/Session/PhpSessionTest.php +++ b/test/php/library/Icinga/Session/PhpSessionTest.php @@ -27,23 +27,9 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -namespace Tests\Icinga\Authentication; - -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -// @codingStandardsIgnoreEnd +namespace Tests\Icinga\Session; use Icinga\Test\BaseTestCase; - -// @codingStandardsIgnoreStart -require_once BaseTestCase::$libDir . '/Web/Session/SessionNamespace.php'; -require_once BaseTestCase::$libDir . '/Web/Session/Session.php'; -require_once BaseTestCase::$libDir . '/Web/Session/PhpSession.php'; -require_once BaseTestCase::$libDir . '/Logger/Logger.php'; -require_once BaseTestCase::$libDir . '/Exception/ConfigurationError.php'; -require_once 'Zend/Log.php'; -// @codingStandardsIgnoreEnd - use Icinga\Web\Session\PhpSession; class PhpSessionTest extends BaseTestCase diff --git a/test/php/library/Icinga/Session/SessionNamespaceTest.php b/test/php/library/Icinga/Session/SessionNamespaceTest.php index af269ffe0..1b6ceb73a 100644 --- a/test/php/library/Icinga/Session/SessionNamespaceTest.php +++ b/test/php/library/Icinga/Session/SessionNamespaceTest.php @@ -27,17 +27,10 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -// @codingStandardsIgnoreStart -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); -// @codingStandardsIgnoreEnd - -use Icinga\Test\BaseTestCase; - -// @codingStandardsIgnoreStart -require_once BaseTestCase::$libDir . '/Web/Session/SessionNamespace.php'; -// @codingStandardsIgnoreEnd +namespace Tests\Icinga\Session; use \Exception; +use Icinga\Test\BaseTestCase; use Icinga\Web\Session\SessionNamespace; diff --git a/test/php/library/Icinga/Test/BaseTestCaseDbTest.php b/test/php/library/Icinga/Test/BaseTestCaseDbTest.php index da25277c8..a1bae5777 100644 --- a/test/php/library/Icinga/Test/BaseTestCaseDbTest.php +++ b/test/php/library/Icinga/Test/BaseTestCaseDbTest.php @@ -29,12 +29,6 @@ namespace Tests\Icinga\Test; -require_once 'Zend/Db/Adapter/Pdo/Mysql.php'; -require_once 'Zend/Db/Adapter/Pdo/Pgsql.php'; -require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); - -use \PDO; -use \RuntimeException; use Icinga\Test\BaseTestCase; class BaseTestCaseDbTest extends BaseTestCase diff --git a/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php b/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php index 1b9423741..363b87fad 100644 --- a/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php +++ b/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php @@ -1,21 +1,11 @@ assertEquals('...', $pages[3]); $this->assertEquals('...', $pages[14]); } - } diff --git a/test/php/library/Icinga/Web/UrlTest.php b/test/php/library/Icinga/Web/UrlTest.php index 21008f808..aed22f1bf 100644 --- a/test/php/library/Icinga/Web/UrlTest.php +++ b/test/php/library/Icinga/Web/UrlTest.php @@ -1,20 +1,15 @@ buildForm(); - $rendered = $form->render($view); - - $this->assertContains("getRequest(); - - $request->setMethod("POST")->setPost( - array( - "username" => "test", - "password" => "test", - "btn_submit" => "1" - ) - ); - - $view = new \Zend_View(); - $form = new LoginForm(); - $form->setRequest($request); - $form->buildForm(); - $this->assertTrue($form->isSubmittedAndValid()); - - } - } - -}