From 10d4a7084cc31570a26746b417ffa47238b9a2a0 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 15 Nov 2021 16:44:19 +0100 Subject: [PATCH] FilterTest: Add HasValue & HasNotValue test cases --- tests/FilterTest.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tests/FilterTest.php b/tests/FilterTest.php index b26b3fc..46d6359 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -12,21 +12,24 @@ class FilterTest extends TestCase 'problem' => '1', 'service' => 'ping', 'state' => 2, - 'handled' => '1' + 'handled' => '1', + 'host_id' => 1 ], [ 'host' => 'localhost', 'problem' => '1', 'service' => 'www.icinga.com', 'state' => 0, - 'handled' => '0' + 'handled' => '0', + 'host_id' => null ], [ 'host' => 'localhost', 'problem' => '1', 'service' => 'www.icinga.com', 'state' => 1, - 'handled' => '0' + 'handled' => '0', + 'host_id' => 1 ] ]; @@ -183,6 +186,34 @@ public function testUnequalMatchesMultiValuedColumns() ])); } + public function testHasValueMatches() + { + $hasValue = Filter::hasValue('host_id'); + + $this->assertTrue(Filter::match($hasValue, $this->row(0))); + } + + public function testHasValueMismatches() + { + $hasValue = Filter::hasValue('host_id'); + + $this->assertFalse(Filter::match($hasValue, $this->row(1))); + } + + public function testHasNotValueMatches() + { + $hasValue = Filter::hasNotValue('host_id'); + + $this->assertTrue(Filter::match($hasValue, $this->row(1))); + } + + public function testHasValueNotMismatches() + { + $hasValue = Filter::hasNotValue('host_id'); + + $this->assertFalse(Filter::match($hasValue, $this->row(0))); + } + public function testGreaterThanMatches() { $greaterThan = Filter::greaterThan('state', 1);