From 4b92edaad59446418d14df0e579d6f4377513fc6 Mon Sep 17 00:00:00 2001 From: dantleech Date: Thu, 11 Sep 2014 22:24:18 +0200 Subject: [PATCH] Fixed parenthesis for NOT negator --- src/PHPCR/Util/QOM/BaseSqlGenerator.php | 2 +- .../PHPCR/Tests/Util/QOM/BaseSqlGeneratorTest.php | 15 +++++++++++++++ tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/PHPCR/Tests/Util/QOM/BaseSqlGeneratorTest.php diff --git a/src/PHPCR/Util/QOM/BaseSqlGenerator.php b/src/PHPCR/Util/QOM/BaseSqlGenerator.php index 1cbb392..dca2e2b 100644 --- a/src/PHPCR/Util/QOM/BaseSqlGenerator.php +++ b/src/PHPCR/Util/QOM/BaseSqlGenerator.php @@ -83,7 +83,7 @@ public function evalOr($constraint1, $constraint2) */ public function evalNot($constraint) { - return "NOT $constraint"; + return "(NOT $constraint)"; } /** diff --git a/tests/PHPCR/Tests/Util/QOM/BaseSqlGeneratorTest.php b/tests/PHPCR/Tests/Util/QOM/BaseSqlGeneratorTest.php new file mode 100644 index 0000000..d5984db --- /dev/null +++ b/tests/PHPCR/Tests/Util/QOM/BaseSqlGeneratorTest.php @@ -0,0 +1,15 @@ +generator->evalNot("foo = bar"); + $this->assertSame("(NOT foo = bar)", $string); + } +} diff --git a/tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php b/tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php index e5cbc75..83f40a7 100644 --- a/tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php +++ b/tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php @@ -5,7 +5,7 @@ use PHPCR\Util\QOM\Sql2Generator; use PHPCR\Util\ValueConverter; -class Sql2GeneratorTest extends \PHPUnit_Framework_TestCase +class Sql2GeneratorTest extends BaseSqlGeneratorTest { protected $generator;