Merge branch 'bugfix/test-fix-6542'

fixes #6542
This commit is contained in:
Eric Lippmann 2014-07-02 11:39:28 +02:00
commit 9b2d674c50
7 changed files with 8 additions and 132 deletions

View File

@ -4,7 +4,7 @@
namespace Icinga\Application;
use Exception;
use Icinga\Exception\ProgrammingError;
class Loader
{
@ -39,7 +39,7 @@ class Loader
public function registerNamespace($namespace, $directory)
{
if (!is_dir($directory)) {
throw new Exception(sprintf(
throw new ProgrammingError(sprintf(
'Namespace directory "%s" for "%s" does not exist',
$namespace,
$directory

View File

@ -31,14 +31,14 @@ namespace Icinga\Protocol\Statusdat;
use Icinga\Util\File;
use Icinga\Logger\Logger;
use Icinga\Data\DatasourceInterface;
use Icinga\Data\Selectable;
use Icinga\Exception\ConfigurationError;
/**
* Class Reader
* @package Icinga\Protocol\Statusdat
*/
class Reader implements IReader, DatasourceInterface
class Reader implements IReader, Selectable
{
/**
* The default lifetime of the cache in milliseconds

View File

@ -111,7 +111,6 @@ EOD;
/**
* @expectedException Icinga\Exception\ProgrammingError
* @expectedExceptionMessage Directory does not exist: /trullalla/123
*/
public function testNonexistingDirectory()
{

View File

@ -15,7 +15,7 @@ class CsvTest extends BaseTestCase
$queryMock = Mockery::mock(
'Icinga\Data\SimpleQuery',
array(
'fetchAll' => array(
'getQuery->fetchAll' => array(
array('col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'),
array('col1' => 'val5', 'col2' => 'val6', 'col3' => 'val7', 'col4' => 'val8')
)

View File

@ -19,7 +19,7 @@ use Icinga\Module\Monitoring\Command\ScheduleCheckCommand;
use Icinga\Module\Monitoring\Command\SubmitPassiveCheckresultCommand;
if (!defined('EXTCMD_TEST_BIN')) {
define('EXTCMD_TEST_BIN', './bin/extcmd_test');
define('EXTCMD_TEST_BIN', BaseTestCase::$testDir . '/bin/extcmd_test');
}
/**

View File

@ -1,72 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Tests\Icinga\Web\Paginator\Adapter;
use \Zend_Config;
use Icinga\Test\BaseTestCase;
use Icinga\Protocol\Statusdat\Reader;
use Icinga\Module\Monitoring\Backend;
use Icinga\Web\Paginator\Adapter\QueryAdapter;
class QueryAdapterTest extends BaseTestCase
{
private $cacheDir;
private $backendConfig;
private $resourceConfig;
public function setUp()
{
parent::setUp();
$this->cacheDir = '/tmp'. Reader::STATUSDAT_DEFAULT_CACHE_PATH;
if (!file_exists($this->cacheDir)) {
mkdir($this->cacheDir);
}
$statusdatFile = BaseTestCase::$testDir . '/res/status/icinga.status.dat';
$cacheFile = BaseTestCase::$testDir . '/res/status/icinga.objects.cache';
$this->backendConfig = new Zend_Config(
array(
'type' => 'statusdat'
)
);
$this->resourceConfig = new Zend_Config(
array(
'status_file' => $statusdatFile,
'object_file' => $cacheFile,
'type' => 'statusdat'
)
);
}
public function testLimit1()
{
$backend = new Backend($this->backendConfig, $this->resourceConfig);
$query = $backend->select()->from('status');
$adapter = new QueryAdapter($query);
$this->assertEquals(30, $adapter->count());
$data = $adapter->getItems(0, 10);
$this->assertCount(10, $data);
$data = $adapter->getItems(10, 20);
$this->assertCount(10, $data);
}
public function testLimit2()
{
$backend = new Backend($this->backendConfig, $this->resourceConfig);
$query = $backend->select()->from('status');
$adapter = new QueryAdapter($query);
$this->assertEquals(30, $adapter->count());
}
}

View File

@ -6,63 +6,12 @@ namespace Tests\Icinga\Web\Paginator\ScrollingStyle;
require_once realpath(ICINGA_LIBDIR . '/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php');
use \Mockery;
use \Zend_Config;
use \Zend_Paginator;
use Mockery;
use Zend_Paginator;
use Icinga\Test\BaseTestCase;
use Icinga\Protocol\Statusdat\Reader;
use Icinga\Web\Paginator\Adapter\QueryAdapter;
use Icinga\Module\Monitoring\Backend;
class SlidingwithborderTest extends BaseTestCase
{
private $cacheDir;
private $backendConfig;
private $resourceConfig;
public function setUp()
{
parent::setUp();
$this->cacheDir = '/tmp'. Reader::STATUSDAT_DEFAULT_CACHE_PATH;
if (!file_exists($this->cacheDir)) {
mkdir($this->cacheDir);
}
$statusdatFile = BaseTestCase::$testDir . '/res/status/icinga.status.dat';
$cacheFile = BaseTestCase::$testDir . '/res/status/icinga.objects.cache';
$this->backendConfig = new Zend_Config(
array(
'type' => 'statusdat'
)
);
$this->resourceConfig = new Zend_Config(
array(
'status_file' => $statusdatFile,
'object_file' => $cacheFile,
'type' => 'statusdat'
)
);
}
public function testGetPages1()
{
$backend = new Backend($this->backendConfig, $this->resourceConfig);
$adapter = new QueryAdapter($backend->select()->from('status'));
$this->assertEquals(30, $adapter->count());
$scrollingStyle = new \Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder();
$paginator = new Zend_Paginator($adapter);
$pages = $scrollingStyle->getPages($paginator);
$this->assertInternalType('array', $pages);
$this->assertCount(3, $pages);
}
public function testGetPages2()
{
$scrollingStyle = new \Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder();