From 56a1af47e7ff73352c6ffb105ef88845f5f7bed4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 1 Oct 2014 03:23:06 +0200 Subject: [PATCH] filter: Add test for whitespace sanitizing --- test/php/library/Icinga/Data/Filter/FilterTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/php/library/Icinga/Data/Filter/FilterTest.php b/test/php/library/Icinga/Data/Filter/FilterTest.php index dbd640b91..b8f9ea78a 100644 --- a/test/php/library/Icinga/Data/Filter/FilterTest.php +++ b/test/php/library/Icinga/Data/Filter/FilterTest.php @@ -199,6 +199,16 @@ class FilterTest extends BaseTestCase $this->assertNotEquals((string) $c, (string) $d); } + public function testLeadingAndTrailingWhitespacesSanitizing() + { + $columnHasWhitespaces = Filter::where(' host ', 'localhost'); + $expressionHasWhitespaces = Filter::where('host', ' localhost '); + $bothHaveWhitespaces = Filter::fromQueryString(' host = localhost '); + $this->assertTrue($columnHasWhitespaces->matches($this->sampleData[0])); + $this->assertTrue($expressionHasWhitespaces->matches($this->sampleData[0])); + $this->assertTrue($bothHaveWhitespaces->matches($this->sampleData[0])); + } + private function row($idx) { return $this->sampleData[$idx];