Evaluate, Test and Move the items und library/Icinga/Web to the source tree
Add test for paginator/QueryAdapter refs #4256
This commit is contained in:
parent
f19934ef39
commit
9657ba565e
|
@ -324,7 +324,12 @@ class Parser
|
|||
*/
|
||||
protected function getMembers(&$object)
|
||||
{
|
||||
if (!isset($object->members)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$members = explode(",", $object->members);
|
||||
|
||||
if ($this->currentObjectType == "service") {
|
||||
$res = array();
|
||||
for ($i = 0; $i < count($members); $i += 2) {
|
||||
|
|
|
@ -95,7 +95,7 @@ class Reader implements IReader
|
|||
*/
|
||||
private function initializeCaches()
|
||||
{
|
||||
$defaultCachePath = "/tmp/" . self::STATUSDAT_DEFAULT_CACHE_PATH;
|
||||
$defaultCachePath = "/tmp" . self::STATUSDAT_DEFAULT_CACHE_PATH;
|
||||
|
||||
$cachePath = $this->config->get('cache_path', $defaultCachePath);
|
||||
$maxCacheLifetime = intval($this->config->get('cache_path', self::DEFAULT_CACHE_LIFETIME));
|
||||
|
@ -167,10 +167,16 @@ class Reader implements IReader
|
|||
*/
|
||||
private function readStatusCache()
|
||||
{
|
||||
if (!isset($this->stateCache)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$statusInfo = $this->stateCache->load('state' . md5($this->config->status_file));
|
||||
|
||||
if ($statusInfo == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->hasRuntimeState = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Icinga\Web\Paginator\Adapter;
|
||||
|
||||
use Icinga\Backend\Statusdat;
|
||||
use Icinga\Protocol\Statusdat\Reader;
|
||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||
|
||||
require_once 'Zend/Paginator/Adapter/Interface.php';
|
||||
require_once 'Zend/Config.php';
|
||||
require_once 'Zend/Cache.php';
|
||||
|
||||
require_once '../../library/Icinga/Web/Paginator/Adapter/QueryAdapter.php';
|
||||
require_once '../../library/Icinga/Backend/Criteria/Order.php';
|
||||
require_once '../../library/Icinga/Backend/AbstractBackend.php';
|
||||
require_once '../../library/Icinga/Backend/Query.php';
|
||||
require_once '../../library/Icinga/Backend/Statusdat/Query.php';
|
||||
require_once '../../library/Icinga/Backend/Statusdat.php';
|
||||
require_once '../../library/Icinga/Backend/MonitoringObjectList.php';
|
||||
require_once '../../library/Icinga/Backend/Statusdat/HostlistQuery.php';
|
||||
require_once '../../library/Icinga/Backend/DataView/AbstractAccessorStrategy.php';
|
||||
require_once '../../library/Icinga/Backend/DataView/ObjectRemappingView.php';
|
||||
require_once '../../library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php';
|
||||
require_once '../../library/Icinga/Protocol/AbstractQuery.php';
|
||||
require_once '../../library/Icinga/Protocol/Statusdat/IReader.php';
|
||||
require_once '../../library/Icinga/Protocol/Statusdat/Reader.php';
|
||||
require_once '../../library/Icinga/Protocol/Statusdat/Query.php';
|
||||
|
||||
class QueryAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $cacheDir;
|
||||
|
||||
private $config;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->cacheDir = '/tmp'. Reader::STATUSDAT_DEFAULT_CACHE_PATH;
|
||||
|
||||
if (!file_exists($this->cacheDir)) {
|
||||
mkdir($this->cacheDir);
|
||||
}
|
||||
|
||||
$statusdatFile = dirname(__FILE__). '/../../../../../res/status/icinga.status.dat';
|
||||
$cacheFile = dirname(__FILE__). '/../../../../../res/status/icinga.objects.cache';
|
||||
|
||||
$this->config = new \Zend_Config(
|
||||
array(
|
||||
'status_file' => $statusdatFile,
|
||||
'objects_file' => $cacheFile
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testLimit1()
|
||||
{
|
||||
$backend = new Statusdat($this->config);
|
||||
$query = $backend->select()->from('hostlist');
|
||||
|
||||
$paginator = new QueryAdapter($query);
|
||||
|
||||
$this->assertEquals(30, $paginator->count());
|
||||
|
||||
$data = $paginator->getItems(0, 10);
|
||||
|
||||
$this->assertCount(10, $data);
|
||||
|
||||
$data = $paginator->getItems(10, 20);
|
||||
$this->assertCount(10, $data);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue