diff --git a/tests/FilterProcessorTest.php b/tests/FilterProcessorTest.php index 315bedc..ccd9e45 100644 --- a/tests/FilterProcessorTest.php +++ b/tests/FilterProcessorTest.php @@ -3,7 +3,9 @@ namespace ipl\Tests\Sql; use ipl\Sql\Compat\FilterProcessor; +use ipl\Sql\Filter\Exists; use ipl\Sql\Filter\In; +use ipl\Sql\Filter\NotExists; use ipl\Sql\Filter\NotIn; use ipl\Sql\Select; use ipl\Stdlib\Filter; @@ -88,9 +90,25 @@ public function testNotInToSql() ['(foo NOT IN (?) OR foo IS NULL)' => $select], FilterProcessor::assemblePredicate(new NotIn(['foo'], $select)) ); + } + + public function testExistsToSql() + { + $select = (new Select())->from('oof')->columns('*')->where(['foo = ?' => 'bar']); + + $this->assertSame( + [' EXISTS ?' => $select], + FilterProcessor::assemblePredicate(new Exists($select)) + ); + } + + public function testNotExistsToSql() + { + $select = (new Select())->from('oof')->columns('*')->where(['foo = ?' => 'bar']); + $this->assertSame( - ['( foo, bar ) NOT IN (?)' => $select], - FilterProcessor::assemblePredicate(new NotIn(['foo', 'bar'], $select)) + [' NOT EXISTS ?' => $select], + FilterProcessor::assemblePredicate(new NotExists(($select))) ); } }