diff --git a/library/Icinga/Application/Loader.php b/library/Icinga/Application/Loader.php index 4bc93f06a..bc31cfbb1 100644 --- a/library/Icinga/Application/Loader.php +++ b/library/Icinga/Application/Loader.php @@ -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 diff --git a/library/Icinga/Protocol/Statusdat/Reader.php b/library/Icinga/Protocol/Statusdat/Reader.php index 4e55a69c0..342e09af1 100644 --- a/library/Icinga/Protocol/Statusdat/Reader.php +++ b/library/Icinga/Protocol/Statusdat/Reader.php @@ -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 diff --git a/test/php/library/Icinga/Application/LoaderTest.php b/test/php/library/Icinga/Application/LoaderTest.php index e2b1c8161..1a0276945 100644 --- a/test/php/library/Icinga/Application/LoaderTest.php +++ b/test/php/library/Icinga/Application/LoaderTest.php @@ -111,7 +111,6 @@ EOD; /** * @expectedException Icinga\Exception\ProgrammingError - * @expectedExceptionMessage Directory does not exist: /trullalla/123 */ public function testNonexistingDirectory() { diff --git a/test/php/library/Icinga/File/CsvTest.php b/test/php/library/Icinga/File/CsvTest.php index afe47c84a..f4ae27c63 100644 --- a/test/php/library/Icinga/File/CsvTest.php +++ b/test/php/library/Icinga/File/CsvTest.php @@ -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') ) diff --git a/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php b/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php index 0ec9a4da6..d7ce01fb0 100644 --- a/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php +++ b/test/php/library/Icinga/Protocol/Commandpipe/CommandPipeTest.php @@ -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'); } /** diff --git a/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php b/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php deleted file mode 100644 index b5d119a5f..000000000 --- a/test/php/library/Icinga/Web/Paginator/Adapter/QueryAdapterTest.php +++ /dev/null @@ -1,72 +0,0 @@ -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()); - } -} diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index 160018c0c..d9eb0b25b 100644 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -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();