From a3ece3b419fa7bfe50ccf2a48d83545aa007fbe8 Mon Sep 17 00:00:00 2001 From: neoglez Date: Mon, 21 Sep 2015 08:52:46 +0200 Subject: [PATCH] UnitTest backport of "Failing test case for broken paginator case" UnitTest backport of "Failing test case for broken paginator case" ( https://github.com/doctrine/doctrine2/commit/192da148428e62cea53fa2b918daf14f85cd7286 ). The branch 2.x is very important because it's related to ZF2 doctrine module (see https://github.com/doctrine/DoctrineORMModule/blob/master/composer.json ) and specially this issue affects the use case of extending the ZF2 user entity defined in ZfcUser ( https://github.com/ZF-Commons/ZfcUser ). This test is meant to show the need of the backport of https://github.com/doctrine/doctrine2/commit/e501137d1afff2c08963828b61b0b8b6668edd83 --- .../LimitSubqueryOutputWalkerTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 40fe1575a..95b9793f6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -350,7 +350,26 @@ ORDER BY b.id DESC' $query->getSQL() ); } + + /** + * This tests ordering by property that has the 'declared' field. + */ + public function testLimitSubqueryOrderByFieldFromMappedSuperclass() + { + $this->entityManager->getConnection()->setDatabasePlatform(new MySqlPlatform()); + // now use the third one in query + $query = $this->entityManager->createQuery( + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC' + ); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); + + $this->assertEquals( + 'SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result ORDER BY id_0 DESC', + $query->getSQL() + ); + } + /** * Tests order by on a subselect expression (mysql). */