mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
6ea048d4ef
commit
8d3ff94696
@ -19,13 +19,14 @@ class Backend
|
|||||||
$name = AuthManager::getInstance()->getSession()->get('backend');
|
$name = AuthManager::getInstance()->getSession()->get('backend');
|
||||||
}
|
}
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
$name = array_shift(array_keys($backends->toArray()));
|
$backendKeys = array_keys($backends->toArray());
|
||||||
|
$name = array_shift($backendKeys);
|
||||||
}
|
}
|
||||||
if (isset($backends->$name)) {
|
if (isset($backends->$name)) {
|
||||||
$config = $backends->$name;
|
$config = $backends->$name;
|
||||||
$type = $config->type;
|
$type = $config->type;
|
||||||
$type[0] = strtoupper($type[0]);
|
$type[0] = strtoupper($type[0]);
|
||||||
$class = '\\Icinga\\Backend\\' . $type;
|
$class = '\\Monitoring\\Backend\\' . $type;
|
||||||
self::$instances[$name] = new $class($config);
|
self::$instances[$name] = new $class($config);
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception(sprintf(
|
throw new \Exception(sprintf(
|
||||||
|
@ -188,7 +188,7 @@ class Parser
|
|||||||
throw new ParsingException("No $this->currentObjectType objects registered in objects.cache");
|
throw new ParsingException("No $this->currentObjectType objects registered in objects.cache");
|
||||||
}
|
}
|
||||||
$base = & $this->icingaState[$this->currentObjectType];
|
$base = & $this->icingaState[$this->currentObjectType];
|
||||||
$state = & $this->skipObject(true);
|
$state = $this->skipObject(true);
|
||||||
$statusdatObject->runtimeState = & $state;
|
$statusdatObject->runtimeState = & $state;
|
||||||
$name = $this->getObjectIdentifier($statusdatObject);
|
$name = $this->getObjectIdentifier($statusdatObject);
|
||||||
|
|
||||||
|
@ -259,9 +259,9 @@ class Query extends AbstractQuery
|
|||||||
$result = array();
|
$result = array();
|
||||||
$source = self::$VALID_TARGETS[$this->source];
|
$source = self::$VALID_TARGETS[$this->source];
|
||||||
foreach ($source as $target) {
|
foreach ($source as $target) {
|
||||||
$indexes = & array_keys($state[$target]);
|
$indexes = array_keys($state[$target]);
|
||||||
if ($baseGroup) {
|
if ($baseGroup) {
|
||||||
$indexes = & $baseGroup->filter($state[$target]);
|
$indexes = $baseGroup->filter($state[$target]);
|
||||||
}
|
}
|
||||||
if (!isset($result[$target])) {
|
if (!isset($result[$target])) {
|
||||||
$result[$target] = $indexes;
|
$result[$target] = $indexes;
|
||||||
@ -292,8 +292,8 @@ class Query extends AbstractQuery
|
|||||||
*/
|
*/
|
||||||
private function orderResult($a, $b)
|
private function orderResult($a, $b)
|
||||||
{
|
{
|
||||||
$o1 = & $this->ds->getObjectByName($this->currentType, $a);
|
$o1 = $this->ds->getObjectByName($this->currentType, $a);
|
||||||
$o2 = & $this->ds->getObjectByName($this->currentType, $b);
|
$o2 = $this->ds->getObjectByName($this->currentType, $b);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
foreach ($this->order_columns as $col) {
|
foreach ($this->order_columns as $col) {
|
||||||
$result += $col[1] * strnatcasecmp($o1->{$col[0]}, $o2->{$col[0]});
|
$result += $col[1] * strnatcasecmp($o1->{$col[0]}, $o2->{$col[0]});
|
||||||
@ -352,7 +352,7 @@ class Query extends AbstractQuery
|
|||||||
$result = array();
|
$result = array();
|
||||||
foreach ($indices as $type => $subindices) {
|
foreach ($indices as $type => $subindices) {
|
||||||
foreach ($subindices as $objectIndex) {
|
foreach ($subindices as $objectIndex) {
|
||||||
$r = & $this->ds->getObjectByName($type, $objectIndex);
|
$r = $this->ds->getObjectByName($type, $objectIndex);
|
||||||
$hash = "";
|
$hash = "";
|
||||||
$cols = array();
|
$cols = array();
|
||||||
foreach ($this->groupColumns as $col) {
|
foreach ($this->groupColumns as $col) {
|
||||||
@ -377,7 +377,7 @@ class Query extends AbstractQuery
|
|||||||
public function getResult()
|
public function getResult()
|
||||||
{
|
{
|
||||||
|
|
||||||
$indices = & $this->getFilteredIndices();
|
$indices = $this->getFilteredIndices();
|
||||||
$this->orderIndices($indices);
|
$this->orderIndices($indices);
|
||||||
if ($this->groupByFn) {
|
if ($this->groupByFn) {
|
||||||
$scope = $this->groupByFn[self::FN_SCOPE];
|
$scope = $this->groupByFn[self::FN_SCOPE];
|
||||||
@ -389,7 +389,7 @@ class Query extends AbstractQuery
|
|||||||
$this->limitIndices($indices);
|
$this->limitIndices($indices);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$state = & $this->ds->getObjects();
|
$state = $this->ds->getObjects();
|
||||||
foreach ($indices as $type => $subindices) {
|
foreach ($indices as $type => $subindices) {
|
||||||
|
|
||||||
foreach ($subindices as $index) {
|
foreach ($subindices as $index) {
|
||||||
|
@ -379,7 +379,8 @@ class Group implements IQueryPart
|
|||||||
if ($this->type == self::TYPE_OR) {
|
if ($this->type == self::TYPE_OR) {
|
||||||
$idx = array();
|
$idx = array();
|
||||||
foreach ($this->items as &$subFilter) {
|
foreach ($this->items as &$subFilter) {
|
||||||
$idx += $subFilter->filter($base, array_keys($base));
|
$baseKeys = array_keys($base);
|
||||||
|
$idx += $subFilter->filter($base, $baseKeys);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!$idx) {
|
if (!$idx) {
|
||||||
|
@ -242,7 +242,7 @@ class Reader implements IReader, DatasourceInterface
|
|||||||
$this->parser = new Parser(fopen($this->config->objects_file, "r"));
|
$this->parser = new Parser(fopen($this->config->objects_file, "r"));
|
||||||
}
|
}
|
||||||
$this->parser->parseObjectsFile();
|
$this->parser->parseObjectsFile();
|
||||||
$this->lastState = & $this->parser->getRuntimeState();
|
$this->lastState = $this->parser->getRuntimeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,7 +259,7 @@ class Reader implements IReader, DatasourceInterface
|
|||||||
$this->parser = new Parser(fopen($this->config->status_file, "r"), $this->lastState);
|
$this->parser = new Parser(fopen($this->config->status_file, "r"), $this->lastState);
|
||||||
}
|
}
|
||||||
$this->parser->parseRuntimeState(fopen($this->config->status_file, "r"));
|
$this->parser->parseRuntimeState(fopen($this->config->status_file, "r"));
|
||||||
$this->lastState = & $this->parser->getRuntimeState();
|
$this->lastState = $this->parser->getRuntimeState();
|
||||||
if (!$this->noCache) {
|
if (!$this->noCache) {
|
||||||
$this->statusCache->save(array("true" => true), "state" . md5($this->config->objects_file));
|
$this->statusCache->save(array("true" => true), "state" . md5($this->config->objects_file));
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,7 @@ class Monitoring_ListController extends ModuleActionController
|
|||||||
-1,
|
-1,
|
||||||
PREG_SPLIT_NO_EMPTY
|
PREG_SPLIT_NO_EMPTY
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->view->extraColumns = $extra;
|
$this->view->extraColumns = $extra;
|
||||||
$query = $this->backend->select()
|
$query = $this->backend->select()
|
||||||
->from($view, array_merge($columns, $extra))
|
->from($view, array_merge($columns, $extra))
|
||||||
|
@ -29,7 +29,11 @@ class Zend_View_Helper_MonitoringFlags extends Zend_View_Helper_Abstract
|
|||||||
*/
|
*/
|
||||||
private function getObjectType(array $vars)
|
private function getObjectType(array $vars)
|
||||||
{
|
{
|
||||||
return array_shift(explode('_', array_shift(array_keys($vars)), 2));
|
$keys = array_keys($vars);
|
||||||
|
$firstKey = array_shift($keys);
|
||||||
|
$keyParts = explode('_', $firstKey, 2);
|
||||||
|
|
||||||
|
return array_shift($keyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +64,9 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
|||||||
*/
|
*/
|
||||||
private function getObjectType(\stdClass $object)
|
private function getObjectType(\stdClass $object)
|
||||||
{
|
{
|
||||||
return array_shift(explode('_', array_shift(array_keys(get_object_vars($object))), 2));
|
$keys = array_keys(get_object_vars($object));
|
||||||
|
$keyParts = explode('_', array_shift($keys), 2);
|
||||||
|
return array_shift($keyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,10 +138,14 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
|||||||
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
|
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
|
||||||
$val .= self::VALUE_NA;
|
$val .= self::VALUE_NA;
|
||||||
} else {
|
} else {
|
||||||
$val .= $this->floatFormatter($object->latency);
|
$val .= $this->floatFormatter(
|
||||||
|
(isset($object->latency)) ? $object->latency : 0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$val .= ' / '. $this->floatFormatter($object->execution_time). ' seconds';
|
$val .= ' / '. $this->floatFormatter(
|
||||||
|
isset($object->execution_time) ? $object->execution_time : 0
|
||||||
|
). ' seconds';
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
$commandParts = preg_split('|!|', $object->check_command);
|
||||||
|
$commandName = array_shift($commandParts);
|
||||||
|
?>
|
||||||
<?= $this->expandable(
|
<?= $this->expandable(
|
||||||
'<b>Command:</b> ' . array_shift(preg_split('|!|', $object->check_command)),
|
'<b>Command:</b> '. $commandName,
|
||||||
$this->commandArguments($object->check_command),
|
$this->commandArguments($object->check_command),
|
||||||
// TODO: no JS handler right now, should be collapsed
|
// TODO: no JS handler right now, should be collapsed
|
||||||
array('collapsed' => ! (bool) strpos($object->check_command, '!'))
|
array('collapsed' => ! (bool) strpos($object->check_command, '!'))
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$checkCommandParts = explode('!', $this->host->host_check_command, 2);
|
||||||
?>
|
?>
|
||||||
<?=
|
<?=
|
||||||
$this->partial(
|
$this->partial(
|
||||||
@ -42,7 +44,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<strong>Command:</strong>
|
<strong>Command:</strong>
|
||||||
<?= array_shift(explode('!', $this->host->host_check_command, 2)); ?>
|
<?= array_shift($checkCommandParts); ?>
|
||||||
<?= $this->commandArguments($this->host->host_check_command); ?>
|
<?= $this->commandArguments($this->host->host_check_command); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,7 +33,7 @@ class Backend
|
|||||||
return key($configs);
|
return key($configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackendConfigs()
|
public static function getBackendConfigs()
|
||||||
{
|
{
|
||||||
if (self::$backendConfigs === null) {
|
if (self::$backendConfigs === null) {
|
||||||
$backends = IcingaConfig::app('backends');
|
$backends = IcingaConfig::app('backends');
|
||||||
@ -45,7 +45,7 @@ class Backend
|
|||||||
return self::$backendConfigs;
|
return self::$backendConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackend($name = null)
|
public static function getBackend($name = null)
|
||||||
{
|
{
|
||||||
if (! array_key_exists($name, self::$instances)) {
|
if (! array_key_exists($name, self::$instances)) {
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
|
@ -39,9 +39,10 @@ class AbstractBackend implements DatasourceInterface
|
|||||||
*
|
*
|
||||||
* Leave fields empty to get all available properties
|
* Leave fields empty to get all available properties
|
||||||
*
|
*
|
||||||
* @param string Virtual table name
|
* @param string $virtual_table Virtual table name
|
||||||
* @param array Fields
|
* @param array $fields Fields
|
||||||
* return self
|
* @throws \Icinga\Exception\ProgrammingError
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function from($virtual_table, $fields = array())
|
public function from($virtual_table, $fields = array())
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,8 @@ abstract class AbstractQuery extends Query
|
|||||||
protected function beforeCreatingSelectQuery()
|
protected function beforeCreatingSelectQuery()
|
||||||
{
|
{
|
||||||
$this->setRealColumns();
|
$this->setRealColumns();
|
||||||
Benchmark::measure(sprintf('%s ready to run', array_pop(explode('\\', get_class($this)))));
|
$classParts = explode('\\', get_class($this));
|
||||||
|
Benchmark::measure(sprintf('%s ready to run', array_pop($classParts)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function applyAllFilters()
|
protected function applyAllFilters()
|
||||||
|
@ -73,7 +73,7 @@ class Statusdat extends AbstractBackend
|
|||||||
* @param $host
|
* @param $host
|
||||||
* @return MonitoringObjectList|null
|
* @return MonitoringObjectList|null
|
||||||
*/
|
*/
|
||||||
public function fetchHost($host)
|
public function fetchHost($host, $fetchAll = false)
|
||||||
{
|
{
|
||||||
$objs = & $this->reader->getObjects();
|
$objs = & $this->reader->getObjects();
|
||||||
|
|
||||||
|
@ -130,6 +130,6 @@ class HostStatusView extends ObjectRemappingView
|
|||||||
*/
|
*/
|
||||||
public function __construct(IReader $reader)
|
public function __construct(IReader $reader)
|
||||||
{
|
{
|
||||||
$this->state = & $reader->getState();
|
$this->state = $reader->getState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,6 @@ class ServiceStatusView extends ObjectRemappingView
|
|||||||
*/
|
*/
|
||||||
public function __construct(IReader $reader)
|
public function __construct(IReader $reader)
|
||||||
{
|
{
|
||||||
$this->state = & $reader->getState();
|
$this->state = $reader->getState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ abstract class GroupsummaryQuery extends Query
|
|||||||
|
|
||||||
foreach ($subIndices as $objName) {
|
foreach ($subIndices as $objName) {
|
||||||
|
|
||||||
$obj = & $this->reader->getObjectByName($type, $objName);
|
$obj = $this->reader->getObjectByName($type, $objName);
|
||||||
$statetype = $this->getStateType($obj);
|
$statetype = $this->getStateType($obj);
|
||||||
foreach ($obj->group as $group) {
|
foreach ($obj->group as $group) {
|
||||||
if (!isset($result[$group])) {
|
if (!isset($result[$group])) {
|
||||||
|
@ -250,7 +250,8 @@ abstract class Query extends AbstractQuery
|
|||||||
{
|
{
|
||||||
$view = $this->viewClass;
|
$view = $this->viewClass;
|
||||||
if (!$this->cursor) {
|
if (!$this->cursor) {
|
||||||
$this->cursor = new MList($this->baseQuery->getResult(), new $view($this->reader));
|
$result = $this->baseQuery->getResult();
|
||||||
|
$this->cursor = new MList($result, new $view($this->reader));
|
||||||
}
|
}
|
||||||
return $this->cursor;
|
return $this->cursor;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,9 @@ class Meta
|
|||||||
*/
|
*/
|
||||||
private function getObjectType(\stdClass $object)
|
private function getObjectType(\stdClass $object)
|
||||||
{
|
{
|
||||||
return array_shift(explode('_', array_shift(array_keys(get_object_vars($object))), 2));
|
$objectKeys = array_keys(get_object_vars($object));
|
||||||
|
$firstKeys = explode('_', array_shift($objectKeys), 2);
|
||||||
|
return array_shift($firstKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,12 +233,13 @@ class MonitoringView extends AbstractQuery
|
|||||||
{
|
{
|
||||||
|
|
||||||
if ($this->query === null) {
|
if ($this->query === null) {
|
||||||
$class = substr(
|
$classParts = preg_split('|\\\|', get_class($this));
|
||||||
array_pop(preg_split('|\\\|', get_class($this))),
|
$class = substr(
|
||||||
0,
|
array_pop($classParts),
|
||||||
-4
|
0,
|
||||||
) . 'Query';
|
-4
|
||||||
$class = '\\' . get_class($this->ds) . '\\Query\\' . $class;
|
) . 'Query';
|
||||||
|
$class = '\\' . get_class($this->ds) . '\\Query\\' . $class;
|
||||||
$query = new $class($this->ds, $this->columns);
|
$query = new $class($this->ds, $this->columns);
|
||||||
foreach ($this->filters as $f) {
|
foreach ($this->filters as $f) {
|
||||||
$query->where($f[0], $f[1]);
|
$query->where($f[0], $f[1]);
|
||||||
|
@ -79,11 +79,15 @@ namespace Icinga\Web
|
|||||||
|
|
||||||
namespace Test\Monitoring\Testlib
|
namespace Test\Monitoring\Testlib
|
||||||
{
|
{
|
||||||
|
require_once 'Zend/View.php';
|
||||||
|
|
||||||
use Icinga\Protocol\Statusdat\Reader;
|
use Icinga\Protocol\Statusdat\Reader;
|
||||||
|
use Icinga\Web\ActionController;
|
||||||
use Test\Monitoring\Testlib\DataSource\TestFixture;
|
use Test\Monitoring\Testlib\DataSource\TestFixture;
|
||||||
use Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
use Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
||||||
use Monitoring\Backend\Ido;
|
use Monitoring\Backend\Ido;
|
||||||
use Monitoring\Backend\Statusdat;
|
use Monitoring\Backend\Statusdat;
|
||||||
|
use \Zend_View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for monitoring controllers that loads required dependencies
|
* Base class for monitoring controllers that loads required dependencies
|
||||||
@ -227,8 +231,13 @@ namespace Test\Monitoring\Testlib
|
|||||||
{
|
{
|
||||||
require_once($this->moduleDir.'/application/controllers/'.$controller.'.php');
|
require_once($this->moduleDir.'/application/controllers/'.$controller.'.php');
|
||||||
$controllerName = '\Monitoring_'.ucfirst($controller);
|
$controllerName = '\Monitoring_'.ucfirst($controller);
|
||||||
|
/** @var ActionController $controller */
|
||||||
$controller = new $controllerName;
|
$controller = new $controllerName;
|
||||||
$controller->setBackend($this->getBackendFor($backend));
|
$controller->setBackend($this->getBackendFor($backend));
|
||||||
|
|
||||||
|
// Many controllers need a view to work properly
|
||||||
|
$controller->view = new Zend_View();
|
||||||
|
|
||||||
return $controller;
|
return $controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,12 @@ use \Icinga\Application\Logger as Logger;
|
|||||||
**/
|
**/
|
||||||
class LoggerTest extends \PHPUnit_Framework_TestCase
|
class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
private $timeZone;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
date_default_timezone_set('GMT');
|
||||||
|
}
|
||||||
|
|
||||||
public function testOverwrite() {
|
public function testOverwrite() {
|
||||||
$cfg1 = new \Zend_Config(array(
|
$cfg1 = new \Zend_Config(array(
|
||||||
|
@ -41,6 +41,10 @@ abstract class LibraryLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public static function requireLibrary();
|
/**
|
||||||
|
* Should be abstract but in php this should not be
|
||||||
|
*/
|
||||||
|
public static function requireLibrary()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
|
|
||||||
$result = & $query->from("services")->getResult();
|
$result = $query->from("services")->getResult();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$this->assertCount(count($objects["service"]), $result);
|
$this->assertCount(count($objects["service"]), $result);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
|
|
||||||
$result = & $query->from("hosts")->getResult();
|
$result = $query->from("hosts")->getResult();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$this->assertCount(count($objects["host"]), $result);
|
$this->assertCount(count($objects["host"]), $result);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
|
|
||||||
$result = &$query->from("services")->limit(2)->getResult();
|
$result = $query->from("services")->limit(2)->getResult();
|
||||||
$this->assertCount(2, $result);
|
$this->assertCount(2, $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
|
|
||||||
$result = & $query->from("services")->limit(2, 4)->getResult();
|
$result = $query->from("services")->limit(2, 4)->getResult();
|
||||||
$this->assertCount(2, $result);
|
$this->assertCount(2, $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->groupByColumns("numeric_val")->getResult();
|
$result = $query->from("services")->groupByColumns("numeric_val")->getResult();
|
||||||
$this->assertCount(3,$result);
|
$this->assertCount(3,$result);
|
||||||
foreach($result as $value) {
|
foreach($result as $value) {
|
||||||
$this->assertTrue(isset($value->count));
|
$this->assertTrue(isset($value->count));
|
||||||
@ -81,7 +81,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->order('numeric_val ASC')->groupByColumns("numeric_val")->getResult();
|
$result = $query->from("services")->order('numeric_val ASC')->groupByColumns("numeric_val")->getResult();
|
||||||
$this->assertCount(3,$result);
|
$this->assertCount(3,$result);
|
||||||
$lastIdx = ~PHP_INT_MAX;
|
$lastIdx = ~PHP_INT_MAX;
|
||||||
foreach($result as $sstatus) {
|
foreach($result as $sstatus) {
|
||||||
@ -101,7 +101,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->order('numeric_val ASC')->getResult();
|
$result = $query->from("services")->order('numeric_val ASC')->getResult();
|
||||||
$lastIdx = ~PHP_INT_MAX;
|
$lastIdx = ~PHP_INT_MAX;
|
||||||
foreach($result as $sstatus) {
|
foreach($result as $sstatus) {
|
||||||
$this->assertGreaterThanOrEqual($lastIdx,$sstatus->numeric_val);
|
$this->assertGreaterThanOrEqual($lastIdx,$sstatus->numeric_val);
|
||||||
@ -114,7 +114,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->order('numeric_val DESC')->getResult();
|
$result = $query->from("services")->order('numeric_val DESC')->getResult();
|
||||||
$lastIdx = PHP_INT_MAX;
|
$lastIdx = PHP_INT_MAX;
|
||||||
foreach($result as $sstatus) {
|
foreach($result as $sstatus) {
|
||||||
$this->assertLessThanOrEqual($lastIdx,$sstatus->numeric_val);
|
$this->assertLessThanOrEqual($lastIdx,$sstatus->numeric_val);
|
||||||
@ -131,17 +131,17 @@ class QueryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$readerMock = $this->getServiceTestReader();
|
$readerMock = $this->getServiceTestReader();
|
||||||
$objects = $readerMock->getObjects();
|
$objects = $readerMock->getObjects();
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->where('numeric_val = ?',array(1))->getResult();
|
$result = $query->from("services")->where('numeric_val = ?',array(1))->getResult();
|
||||||
foreach($result as $testresult) {
|
foreach($result as $testresult) {
|
||||||
$this->assertEquals($testresult->numeric_val,1);
|
$this->assertEquals($testresult->numeric_val,1);
|
||||||
}
|
}
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->where('numeric_val < ? OR numeric_val = ?',array(2,3))->getResult();
|
$result = $query->from("services")->where('numeric_val < ? OR numeric_val = ?',array(2,3))->getResult();
|
||||||
foreach($result as $testresult) {
|
foreach($result as $testresult) {
|
||||||
$this->assertNotEquals($testresult->numeric_val,2);
|
$this->assertNotEquals($testresult->numeric_val,2);
|
||||||
}
|
}
|
||||||
$query = new Statusdat\Query($readerMock);
|
$query = new Statusdat\Query($readerMock);
|
||||||
$result = &$query->from("services")->where('numeric_val < ? OR numeric_val = ?',array(2,3))->where("numeric_val = ?",array(1))->getResult();
|
$result = $query->from("services")->where('numeric_val < ? OR numeric_val = ?',array(2,3))->where("numeric_val = ?",array(1))->getResult();
|
||||||
foreach($result as $testresult) {
|
foreach($result as $testresult) {
|
||||||
$this->assertEquals($testresult->numeric_val,1);
|
$this->assertEquals($testresult->numeric_val,1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user