From a6448f5c77bc0709fc1bb1433d014d30f0dd0e16 Mon Sep 17 00:00:00 2001 From: Kristopher Wilson Date: Sat, 14 Feb 2015 15:35:02 -0500 Subject: [PATCH] make QueryBuilder::getAllAliases public --- lib/Doctrine/ORM/QueryBuilder.php | 2 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index bb08514eb..33d5c68c5 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -473,7 +473,7 @@ class QueryBuilder * * @return array */ - private function getAllAliases() { + public function getAllAliases() { return array_merge($this->getRootAliases(),array_keys($this->joinRootAliases)); } diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index d523f6f49..7beb1ff43 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -1120,4 +1120,26 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals($dql, $dql2); } + + public function testGetAllAliasesWithNoJoins() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $aliases = $qb->getAllAliases(); + + $this->assertEquals(['u'], $aliases); + } + + public function testGetAllAliasesWithJoins() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->join('u.groups', 'g'); + + $aliases = $qb->getAllAliases(); + + $this->assertEquals(['u', 'g'], $aliases); + } }