From 445a7c04cd87866c4ac5285d179e3f8326f3004c Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Tue, 9 Apr 2013 22:26:58 -0500 Subject: [PATCH] DDC-1048 add failing test case --- by cordoval your friend --- .../ORM/Functional/Ticket/DDC1048Test.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1048Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1048Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1048Test.php new file mode 100644 index 00000000000..f75752cc622 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1048Test.php @@ -0,0 +1,70 @@ + + * @package Doctrine\Tests\ORM\Functional\Ticket + */ +class DDC1048Test extends \Doctrine\Tests\OrmFunctionalTestCase +{ + public function setUp() + { + $this->useModelSet('generic'); + parent::setUp(); + } + + /** + * @group DDC-1048 + */ + public function testBugOnDQLForFalseValue() + { + $true = new BooleanModel(); + $true->booleanField = true; + + $false = new BooleanModel(); + $false->booleanField = false; + + $this->_em->persist($true); + $this->_em->persist($false); + $this->_em->flush(); + $this->_em->clear(); + + $qb = $this->_em->createQueryBuilder() + ->select('x') + ->from('Doctrine\Tests\Models\Generic\BooleanModel', 'x') + ; + + $false = $qb + ->where($qb->expr()->andX( + $qb->expr()->eq('x.booleanField', false), + $qb->expr()->eq('x.booleanField', false) + )) + ->orderBy('x.booleanField', 'DESC') + ->getQuery() + ->execute() + ; + + $true = $qb + ->where($qb->expr()->andX( + $qb->expr()->eq('x.booleanField', true), + $qb->expr()->eq('x.booleanField', true) + )) + ->orderBy('x.booleanField', 'DESC') + ->getQuery() + ->execute() + ; + + $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $true, "True model not found"); + $this->assertTrue($true->booleanField, "True Boolean Model should be true."); + + $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $false, "False model not found"); + $this->assertFalse($false->booleanField, "False Boolean Model should be false."); + } +} \ No newline at end of file