Clean up tests [WIP]

refs #4639
This commit is contained in:
Marius Hein 2014-02-14 17:11:49 +01:00 committed by Johannes Meyer
parent 0ca0eef311
commit 34822d9a02
26 changed files with 39 additions and 248 deletions

View File

@ -1,19 +1,9 @@
<?php
namespace Test\Monitoring\Application\Controllers\ListController;
require_once realpath(__DIR__ . '/../../../../../../library/Icinga/Test/BaseTestCase.php');
namespace Icinga\Modules\Monitoring\Test\Application\Controllers\ListController;
use Icinga\Test\BaseTestCase;
require_once(realpath(BaseTestCase::$moduleDir . '/monitoring/test/php/testlib/MonitoringControllerTest.php'));
require_once(realpath(BaseTestCase::$libDir . '/Data/Db/TreeToSqlParser.php'));
require_once(realpath(BaseTestCase::$moduleDir . '/monitoring/library/Monitoring/DataView/DataView.php'));
require_once(realpath(BaseTestCase::$moduleDir . '/monitoring/library/Monitoring/DataView/HostStatus.php'));
require_once(realpath(BaseTestCase::$moduleDir . '/monitoring/library/Monitoring/DataView/Notification.php'));
require_once(realpath(BaseTestCase::$moduleDir . '/monitoring/library/Monitoring/DataView/Downtime.php'));
use Test\Monitoring\Testlib\MonitoringControllerTest;
use Test\Monitoring\Testlib\Datasource\TestFixture;
use Test\Monitoring\Testlib\Datasource\ObjectFlags;

View File

@ -30,7 +30,7 @@ class TestInit
}
$baseNs = 'Icinga\\Module\\' . ucfirst($module);
$moduleLibraryPath = $modulePath . '/' . $module . '/library';
$moduleLibraryPath = $modulePath . '/' . $module . '/library/' . ucfirst($module);
if (is_dir($moduleLibraryPath)) {
$loader->registerNamespace($baseNs, $moduleLibraryPath);

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Form\Config;
namespace Icinga\Test\Form\Config;
use Icinga\Test\BaseTestCase;

View File

@ -27,32 +27,15 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Form\Config;
// @codingStandardsIgnoreStart
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
// @codingStandardsIgnoreEnd
use Icinga\Test\BaseTestCase;
// @codingStandardsIgnoreStart
require_once 'Zend/Form.php';
require_once 'Zend/Config.php';
require_once 'Zend/Config/Ini.php';
require_once 'Zend/View/Helper/Abstract.php';
require_once BaseTestCase::$libDir . '/Web/Form.php';
require_once BaseTestCase::$appDir . '/forms/Config/GeneralForm.php';
require_once BaseTestCase::$appDir . '/views/helpers/DateFormat.php';
require_once BaseTestCase::$libDir . '/Util/ConfigAwareFactory.php';
require_once BaseTestCase::$libDir . '/Util/DateTimeFactory.php';
require_once BaseTestCase::$libDir . '/Util/Translator.php';
// @codingStandardsIgnoreEnd
namespace Icinga\Test\Form\Config;
use \DateTimeZone;
use \DOMDocument;
use \Zend_Config;
use \Zend_View;
use \Zend_View_Helper_DateFormat;
use \Icinga\Util\DateTimeFactory;
use Icinga\Util\DateTimeFactory;
use Icinga\Test\BaseTestCase;
class GeneralFormTest extends BaseTestCase
{

View File

@ -27,23 +27,10 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Form\Config;
// @codingStandardsIgnoreStart
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
// @codingStandardsIgnoreEnd
use Icinga\Test\BaseTestCase;
// @codingStandardsIgnoreStart
require_once 'Zend/Form.php';
require_once 'Zend/Config.php';
require_once 'Zend/Config/Ini.php';
require_once BaseTestCase::$libDir . '/Web/Form.php';
require_once BaseTestCase::$appDir . '/forms/Config/GeneralForm.php';
require_once BaseTestCase::$appDir . '/forms/Config/LoggingForm.php';
// @codingStandardsIgnoreEnd
namespace Icinga\Test\Form\Config;
use \Zend_Config;
Use Icinga\Test\BaseTestCase;
/**
* Test for the authentication provider form

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Form\Preference;
namespace Icinga\Test\Form\Preference;
// @codingStandardsIgnoreStart
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');

View File

@ -36,17 +36,6 @@ use Icinga\Chart\GridChart;
use Icinga\Test\BaseTestCase;
use Test\Icinga\LibraryLoader;
// TODO: Use autoloader #4673
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
require_once realpath(BaseTestCase::$testDir . '/library/Icinga/LibraryLoader.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Drawable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Styleable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Animatable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Unit/AxisUnit.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Unit/LinearUnit.php');
LibraryLoader::loadFolder(realpath(BaseTestCase::$libDir . '/Chart'));
class GraphChartTest extends BaseTestCase
{
public function testBarChartCreation()

View File

@ -27,26 +27,14 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Chart;
namespace Icinga\Tests\Chart;
use DOMXPath;
use DOMDocument;
use \DOMXPath;
use \DOMDocument;
use Icinga\Chart\GridChart;
use Icinga\Chart\PieChart;
use Icinga\Test\BaseTestCase;
use Test\Icinga\LibraryLoader;
// TODO: Use autoloader #4673
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
require_once realpath(BaseTestCase::$testDir . '/library/Icinga/LibraryLoader.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Drawable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Styleable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Primitive/Animatable.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Unit/AxisUnit.php');
require_once realpath(BaseTestCase::$libDir . '/Chart/Unit/LinearUnit.php');
LibraryLoader::loadFolder(realpath(BaseTestCase::$libDir . '/Chart'));
class PieChartTest extends BaseTestCase
{

View File

@ -1,5 +1,5 @@
<?php
namespace Test\Icinga;
namespace Icinga\Test;
abstract class LibraryLoader {

View File

@ -1,59 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - 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 <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Protocol\Commandpipe;
require_once('./library/Icinga/LibraryLoader.php');
use Test\Icinga\LibraryLoader;
class CommandPipeLoader extends LibraryLoader {
public static function requireLibrary()
{
require_once('Zend/Config.php');
require_once('Zend/Log.php');
require_once(realpath('../../library/Icinga/Application/Logger.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Command.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Comment.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/CommandPipe.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/PropertyModifier.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Transport/Transport.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Transport/SecureShell.php'));
require_once(realpath('../../library/Icinga/Protocol/Commandpipe/Transport/LocalPipe.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/AcknowledgeCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/AddCommentCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/ScheduleDowntimeCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/CustomNotificationCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/DelayNotificationCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/ScheduleCheckCommand.php'));
require_once(realpath('../../modules/monitoring/library/Monitoring/Command/SubmitPassiveCheckresultCommand.php'));
}
}

View File

@ -27,13 +27,10 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Protocol\Commandpipe;
namespace Icinga\Tests\Protocol\Commandpipe;
require_once(realpath(__DIR__ . '/CommandPipeLoader.php'));
CommandPipeLoader::requireLibrary();
use Zend_Config;
use PHPUnit_Framework_TestCase;
use \Zend_Config;
use \PHPUnit_Framework_TestCase;
use Icinga\Protocol\Commandpipe\Comment;
use Icinga\Protocol\Commandpipe\Commandpipe as Commandpipe;
use Icinga\Protocol\Commandpipe\PropertyModifier as MONFLAG;

View File

@ -1,8 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once("Zend/Config.php");;
require_once("Zend/Log.php");;
use \Icinga\Protocol\Statusdat as SD;
@ -13,8 +11,6 @@ use \Icinga\Protocol\Statusdat as SD;
class StatusdatComponentTest extends \PHPUnit_Framework_TestCase
{
public function getReader() {
require_once(dirname(__FILE__)."/../StatusdatTestLoader.php");
StatusdatTestLoader::requireLibrary();
$reader = new SD\Reader(new \Zend_Config(array(
"status_file" => dirname(__FILE__)."/status.dat",
"object_file" => dirname(__FILE__)."/objects.cache"

View File

@ -1,10 +1,9 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once(realpath("../../library/Icinga/Protocol/Statusdat/Exception/ParsingException.php"));
require_once(realpath("../../library/Icinga/Exception/ProgrammingError.php"));
require_once(realpath("../../library/Icinga/Protocol/Statusdat/Parser.php"));
use Icinga\Protocol\Statusdat\Parser;
/**
*
* Test class for Parser

View File

@ -1,9 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat\Query;
require_once("../../library/Icinga/Protocol/Statusdat/Query/IQueryPart.php");
require_once("../../library/Icinga/Protocol/Statusdat/Query/Expression.php");
namespace Icinga\Tests\Protocol\Statusdat\Query;
use Icinga\Protocol\Statusdat\Query\Expression;

View File

@ -1,8 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat\Query;
require_once("../../library/Icinga/Protocol/Statusdat/Query/IQueryPart.php");
require_once("../../library/Icinga/Protocol/Statusdat/Query/Group.php");
namespace Icinga\Tests\Protocol\Statusdat\Query;
/**
*
@ -50,7 +48,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase
{
$testQuery = new Statusdat\Query\Group();
$value = array(4);
$testQuery->fromString("numeric_val >= ?", $value, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock");
$testQuery->fromString("numeric_val >= ?", $value, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock");
$this->assertCount(1, $testQuery->getItems());
$this->assertCount(0, $value);
@ -66,7 +64,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase
{
$testQuery = new Statusdat\Query\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, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock");
$this->assertCount(2, $testQuery->getItems());
$this->assertCount(0, $value);
$this->assertEquals("AND", $testQuery->getType());
@ -85,7 +83,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase
{
$testQuery = new Statusdat\Query\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, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock");
$this->assertCount(2, $testQuery->getItems());
$this->assertCount(0, $value);
$this->assertEquals("OR", $testQuery->getType());
@ -104,7 +102,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, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock");
$testQuery->fromString("numeric_val >= ? AND (service_description = ? OR host_name = ?)", $value, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock");
$this->assertCount(2, $testQuery->getItems());
$this->assertCount(0, $value);
$this->assertEquals("AND", $testQuery->getType());
@ -132,7 +130,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, "Tests\Icinga\Protocol\Statusdat\Query\QueryExpressionMock");
$testQuery->fromString("numeric_val >= ? AND service_description = ? OR host_name = ?", $value, "Icinga\Tests\Protocol\Statusdat\Query\QueryExpressionMock");
$this->assertCount(2, $testQuery->getItems());
$this->assertCount(0, $value);
$this->assertEquals("AND", $testQuery->getType());

View File

@ -1,10 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once('../../library/Icinga/Filter/Filterable.php');
require_once('../../library/Icinga/Data/BaseQuery.php');
require_once('../../library/Icinga/Protocol/Statusdat/Query.php');
require_once(dirname(__FILE__)."/ReaderMock.php");
namespace Icinga\Tests\Protocol\Statusdat;
use Icinga\Protocol\Statusdat as Statusdat;
@ -93,6 +89,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
private function getServiceTestReader()
{
require_once('ReaderMock.php');
$readerMock = new ReaderMock(array(
"host" => array(
"hosta" => (object) array(

View File

@ -1,7 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once("../../library/Icinga/Protocol/Statusdat/IReader.php");
require_once(realpath("../../library/Icinga/Data/DatasourceInterface.php"));
namespace Icinga\Tests\Protocol\Statusdat;
use Icinga\Data\DatasourceInterface;
use Icinga\Protocol\Statusdat\IReader;

View File

@ -1,13 +1,9 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once("StatusdatTestLoader.php");
namespace Icinga\Tests\Protocol\Statusdat;
use Icinga\Protocol\Statusdat\Reader as Reader;
StatusdatTestLoader::requireLibrary();
if (!defined('APPLICATION_PATH')) {
define("APPLICATION_PATH", "./"); // TODO: test boostrap
}

View File

@ -1,8 +1,6 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
require_once("../../library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php");
namespace Icinga\Tests\Protocol\Statusdat;
class RuntimestatecontainerTest extends \PHPUnit_Framework_TestCase
{

View File

@ -1,37 +0,0 @@
<?php
namespace Tests\Icinga\Protocol\Statusdat;
use Test\Icinga\LibraryLoader;
require_once(realpath(dirname(__FILE__) . '/../../LibraryLoader.php'));
class StatusdatTestLoader extends LibraryLoader
{
public static function requireLibrary()
{
$libPath = LibraryLoader::getLibraryPath();
require_once 'Zend/Config.php';
require_once 'Zend/Cache.php';
require_once 'Zend/Log.php';
require_once($libPath . '/Data/BaseQuery.php');
require_once($libPath . '/Application/Logger.php');
require_once($libPath . '/Filter/Filterable.php');
require_once($libPath . '/Data/DatasourceInterface.php');
$statusdat = realpath($libPath . '/Protocol/Statusdat/');
require_once($statusdat . '/View/AccessorStrategy.php');
require_once($statusdat . '/PrintableObject.php');
require_once($statusdat . '/View/MonitoringObjectList.php');
require_once($statusdat . '/ObjectContainer.php');
require_once($statusdat . '/IReader.php');
require_once($statusdat . '/RuntimeStateContainer.php');
require_once($statusdat . '/Query.php');
require_once($statusdat . '/Parser.php');
require_once($statusdat . '/Reader.php');
require_once($statusdat . '/TreeToStatusdatQueryParser.php');
require_once($statusdat . '/Exception/ParsingException.php');
require_once($statusdat . '/Query/IQueryPart.php');
require_once($statusdat . '/Query/Expression.php');
require_once($statusdat . '/Query/Group.php');
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Test\Icinga\Web\Form\Element;
namespace Icinga\Test\Web\Form\Element;
use Icinga\Test\BaseTestCase;
require_once 'Zend/Form/Element/Text.php';

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Web\Form\Validator;
namespace Icinga\Test\Web\Form\Validator;
require_once('Zend/Validate/Abstract.php');
require_once(realpath('../../library/Icinga/Web/Form/Validator/DateFormatValidator.php'));

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Web\Form\Validator;
namespace Icinga\Test\Web\Form\Validator;
require_once('Zend/Validate/Abstract.php');
require_once(realpath('../../library/Icinga/Web/Form/Validator/TimeFormatValidator.php'));

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Icinga\Web\Form\Validator;
namespace Icinga\Test\Web\Form\Validator;
require_once('Zend/Validate/Abstract.php');
require_once(realpath('../../library/Icinga/Web/Form/Validator/WritablePathValidator.php'));

View File

@ -1,6 +1,6 @@
<?php
namespace Tests\Icinga\Web\Paginator\Adapter;
namespace Icinga\Tests\Web\Paginator\Adapter;
use PHPUnit_Framework_TestCase;
use Zend_Config;
@ -9,19 +9,6 @@ use Icinga\Web\Paginator\Adapter\QueryAdapter;
use Icinga\Module\Monitoring\Backend;
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
require_once 'Zend/Paginator/Adapter/Interface.php';
require_once '../../library/Icinga/Web/Paginator/Adapter/QueryAdapter.php';
require_once 'library/Icinga/Protocol/Statusdat/StatusdatTestLoader.php';
StatusdatTestLoader::requireLibrary();
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusdatQuery.php';
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php';
require_once '../../modules/monitoring/library/Monitoring/Backend.php';
require_once '../../library/Icinga/Data/BaseQuery.php';
require_once '../../library/Icinga/Data/ResourceFactory.php';
class QueryAdapterTest extends PHPUnit_Framework_TestCase
{
private $cacheDir;

View File

@ -1,6 +1,8 @@
<?php
namespace Tests\Icinga\Web\Paginator\ScrollingStyle;
namespace Icinga\Tests\Web\Paginator\ScrollingStyle;
require_once('Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php');
use Zend_Config;
use Zend_Paginator_Adapter_Interface;
@ -10,22 +12,6 @@ use Icinga\Web\Paginator\Adapter\QueryAdapter;
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
use Icinga\Module\Monitoring\Backend;
require_once 'Zend/Paginator/Adapter/Interface.php';
require_once 'Zend/Paginator/ScrollingStyle/Interface.php';
require_once 'Zend/Paginator.php';
require_once 'Zend/Config.php';
require_once 'Zend/Cache.php';
require_once '../../library/Icinga/Web/Paginator/Adapter/QueryAdapter.php';
require_once 'library/Icinga/Protocol/Statusdat/StatusdatTestLoader.php';
StatusdatTestLoader::requireLibrary();
require_once '../../modules/monitoring/library/Monitoring/Backend.php';
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusdatQuery.php';
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php';
require_once '../../library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php';
class TestPaginatorAdapter implements Zend_Paginator_Adapter_Interface
{
private $items = array();