mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
FilterTest: add notes for future tests
Also removed forgotten sample code
This commit is contained in:
parent
4591297e56
commit
40a3c0d19b
@ -16,19 +16,15 @@ use Icinga\Data\Filter\Filter;
|
|||||||
* !!problem
|
* !!problem
|
||||||
* problem=0
|
* problem=0
|
||||||
* problem=1
|
* problem=1
|
||||||
* problem=true
|
|
||||||
* problem=false
|
|
||||||
*
|
*
|
||||||
* Text-Search
|
* Text-Search
|
||||||
* service=ping
|
* service=ping
|
||||||
* service!=ping
|
* service!=ping
|
||||||
* service=*www*
|
* service=*www*
|
||||||
* !service=*www*
|
* !service=*www*
|
||||||
* hostgroup=www1|www2|!db
|
* hostgroup=(www1|www2)
|
||||||
* hostgroup=[www1,www2]
|
|
||||||
* hostgroup=www1&hostgroup=www2
|
* hostgroup=www1&hostgroup=www2
|
||||||
* host[community]=public
|
* _host_community=public
|
||||||
* _hostcommunity=public
|
|
||||||
*
|
*
|
||||||
* Less/greater than:
|
* Less/greater than:
|
||||||
* state>=1
|
* state>=1
|
||||||
@ -38,6 +34,24 @@ use Icinga\Data\Filter\Filter;
|
|||||||
*
|
*
|
||||||
* Time
|
* Time
|
||||||
*
|
*
|
||||||
|
* Some complex filters that should be tested:
|
||||||
|
*
|
||||||
|
* !host=a!*(n => NOT host = "a!*(n"
|
||||||
|
*
|
||||||
|
* !service_problem&service_handled (regression for #6554)
|
||||||
|
*
|
||||||
|
* Additional nestings just to test a bunch of not/and combinations:
|
||||||
|
*
|
||||||
|
* service_problem=1&!((!((!(service_handled=1)&host_problem=1)))&!host=abc*
|
||||||
|
*
|
||||||
|
* !service_problem=1&(((((service_handled=1)))))
|
||||||
|
*
|
||||||
|
* !service_problem&(((((service_handled)))))&host=abc*
|
||||||
|
*
|
||||||
|
* !service_problem&(((((service_handled))&!service_problem=1)))
|
||||||
|
*
|
||||||
|
* !!(!((host<net*))&!(!(service=srva&host=hosta)|(service=srvb&host=srvb)))
|
||||||
|
*
|
||||||
* What about ~?
|
* What about ~?
|
||||||
*/
|
*/
|
||||||
class FilterTest extends BaseTestCase
|
class FilterTest extends BaseTestCase
|
||||||
@ -146,61 +160,6 @@ class FilterTest extends BaseTestCase
|
|||||||
)->matches($this->row(1))
|
)->matches($this->row(1))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/* NOT YET
|
|
||||||
public function testFilterMatchesArrayWithWildcards()
|
|
||||||
{
|
|
||||||
$this->assertTrue(
|
|
||||||
Filter::where(
|
|
||||||
'service',
|
|
||||||
array('nada', 'nothing', 'www*icinga*')
|
|
||||||
)->matches($this->row(1))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Playing around to get ready for new queryString parser
|
|
||||||
public function testFromQueryString()
|
|
||||||
{
|
|
||||||
$string = 'host_name=localhost&(service_state=1|service_state=2|service_state=3)&service_problem=1';
|
|
||||||
$string = 'host=localhost|(host=none&service=ping)|host=www&limit=10&sort=host';
|
|
||||||
|
|
||||||
echo "Parsing: $string\n";
|
|
||||||
$pos = 0;
|
|
||||||
echo $this->readUnless($string, array('=', '(', '&', '|'), $pos);
|
|
||||||
$sign = $this->readChar($string, $pos);
|
|
||||||
var_dump($sign);
|
|
||||||
echo $this->readUnless($string, array('=', '(', '&', '|'), $pos);
|
|
||||||
echo "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function readChar($string, & $pos)
|
|
||||||
{
|
|
||||||
if (strlen($string) > $pos) {
|
|
||||||
return $string[$pos++];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function readUnless(& $string, $char, & $pos)
|
|
||||||
{
|
|
||||||
$buffer = '';
|
|
||||||
while ($c = $this->readChar($string, $pos)) {
|
|
||||||
if (is_array($char)) {
|
|
||||||
if (in_array($c, $char)) {
|
|
||||||
$pos--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($c === $char) {
|
|
||||||
$pos--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$buffer .= $c;
|
|
||||||
}
|
|
||||||
return $buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testManualFilterCreation()
|
public function testManualFilterCreation()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user