From 4e99c5c127c810bf63c9a371f87f0ff5c82e3e79 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Tue, 11 Jun 2013 01:21:47 -0400 Subject: [PATCH] DDC-1858 Added coverage to ticket. Functionality already implemented. --- .../ORM/Query/LanguageRecognitionTest.php | 8 +++++ .../ORM/Query/SelectSqlGenerationTest.php | 30 ++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index f71c5c7f1..ca9085457 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -590,6 +590,14 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase { $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u"); } + + /** + * @gorup DDC-1858 + */ + public function testHavingSupportIsNullExpression() + { + $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL"); + } } /** @Entity */ diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 26a6a1ec1..e311214b1 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1916,7 +1916,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase { $connMock = $this->_em->getConnection(); $orgPlatform = $connMock->getDatabasePlatform(); - + $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", @@ -1926,7 +1926,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", "SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" ); - + $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", @@ -1936,7 +1936,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", "SELECT c0_.id || c0_.name || c0_.status AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" ); - + $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SQLServerPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", @@ -1946,7 +1946,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", "SELECT (c0_.id + c0_.name + c0_.status) AS sclr0 FROM cms_users c0_ WITH (NOLOCK) WHERE c0_.id = ?" ); - + $connMock->setDatabasePlatform($orgPlatform); } @@ -1986,6 +1986,28 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase 'SELECT r0_.id AS id0, r1_.id AS id1, r1_.passengerName AS passengerName2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName DESC' ); } + + /** + * @group DDC-1858 + */ + public function testHavingSupportIsNullExpression() + { + $this->assertSqlGeneration( + 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL', + 'SELECT c0_.name AS name0 FROM cms_users c0_ HAVING c0_.username IS NULL' + ); + } + + /** + * @group DDC-1858 + */ + public function testHavingSupportResultVariableInExpression() + { + $this->assertSqlGeneration( + 'SELECT u.name AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING foo IN (?1)', + 'SELECT c0_.name AS name0 FROM cms_users c0_ HAVING name0 IN (?)' + ); + } } class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode