1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Merge pull request #1303 from mrkrstphr/querybuilder-get-all-aliases

make QueryBuilder::getAllAliases public
This commit is contained in:
Marco Pivetta 2015-03-17 23:33:43 +00:00
commit 4daf383e4f
2 changed files with 23 additions and 1 deletions

View File

@ -473,7 +473,7 @@ class QueryBuilder
* </code> * </code>
* @return array * @return array
*/ */
private function getAllAliases() { public function getAllAliases() {
return array_merge($this->getRootAliases(),array_keys($this->joinRootAliases)); return array_merge($this->getRootAliases(),array_keys($this->joinRootAliases));
} }

View File

@ -1150,4 +1150,26 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals($dql, $dql2); $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);
}
} }