From f898e2e367592efd23de0581620a271fd3bcbf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Mon, 10 Jun 2013 16:44:58 +0200 Subject: [PATCH] Fix broken files in Statusdat Expression handler The function tokens in the Expression handler didn't work after they were rewritten, as the rewrite was missing in certain files. This is fixed now refs #4246 --- .../Icinga/Protocol/Statusdat/Query/Expression.php | 4 ++-- .../Protocol/Statusdat/Query/ExpressionTest.php | 7 ++++--- .../library/Icinga/Protocol/Statusdat/ReaderTest.php | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/library/Icinga/Protocol/Statusdat/Query/Expression.php b/library/Icinga/Protocol/Statusdat/Query/Expression.php index 6d67fbeeb..c4cdb17e3 100755 --- a/library/Icinga/Protocol/Statusdat/Query/Expression.php +++ b/library/Icinga/Protocol/Statusdat/Query/Expression.php @@ -212,10 +212,10 @@ class Expression implements IQueryPart return false; } - if ($this->CB == "IS_IN") { + if ($this->CB == "isIn") { return count(array_intersect($values, $this->value)) > 0; } - if ($this->CB == "IS_NOT_IN") { + if ($this->CB == "isNotIn") { return count(array_intersect($values, $this->value)) == 0; } if ($this->function) { diff --git a/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php b/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php index 7114c9873..f694bfdcf 100755 --- a/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/Query/ExpressionTest.php @@ -23,14 +23,14 @@ class ExpressionTest extends \PHPUnit_Framework_TestCase public function testFromStringParsing() { $assertions = array( - "expression > ?" => "IS_GREATER", + "expression > ?" => "isGreater", "expression >= ?" => "isGreaterEq", "expression <= ?" => "isLessEq", "expression < ?" => "isLess", "expression = ?" => "isEqual", "expression != ?" => "isNotEqual", "expression like ?" => "isLike", - "expression IN ? " => "IS_IN" + "expression IN ? " => "isIn" ); foreach ($assertions as $query => $callback) { @@ -126,7 +126,8 @@ class ExpressionTest extends \PHPUnit_Framework_TestCase } - public function testCountQuery() { + public function testCountQuery() + { $testArray = array( (object)array( "expression" => "atest", diff --git a/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php b/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php index 6588f75f3..0ec82d168 100755 --- a/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/ReaderTest.php @@ -45,7 +45,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase public function testFileCaching() { $parser = new ParserMock(); - @system("rm ./tmp/zend_cache*"); + @system("rm /tmp/zend_cache*"); $parser->runtime = array("host"=>array( "test" => (object) array( "host_name" => "test" @@ -54,21 +54,21 @@ class ReaderTest extends \PHPUnit_Framework_TestCase $object_file = tempnam("./dir","object"); $status_file = tempnam("./dir","status"); $reader = new Reader(new ConfigMock(array( - "cache_path" => "./tmp", + "cache_path" => "/tmp", "objects_file" => $object_file, "status_file" => $status_file )),$parser); unlink($object_file); unlink($status_file); - $this->assertTrue(file_exists("./tmp/zend_cache---objects".md5($object_file))); - $this->assertTrue(file_exists("./tmp/zend_cache---state".md5($object_file))); - system("rm ./tmp/zend_cache*"); + $this->assertTrue(file_exists("/tmp/zend_cache---objects".md5($object_file))); + $this->assertTrue(file_exists("/tmp/zend_cache---state".md5($object_file))); + system("rm /tmp/zend_cache*"); } public function testEmptyFileException() { $this->setExpectedException("Icinga\Exception\ConfigurationError"); $parser = new ParserMock(); $reader = new Reader(new ConfigMock(array( - "cache_path" => "./tmp", + "cache_path" => "/tmp", "objects_file" => "", "status_file" => "", )),$parser);