1
0
mirror of synced 2024-12-04 18:56:06 +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>
* @return array
*/
private function getAllAliases() {
public function getAllAliases() {
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);
}
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);
}
}