/** * Gets the root entity alias of the query. * * @param QueryBuilder $qb * @param bool $throwException * * @return string|null * * @throws Exception\InvalidEntityException * * @deprecated since 1.9. Use QueryUtils::getSingleRootAlias instead */ public function getSingleRootAlias(QueryBuilder $qb, $throwException = true) { return QueryUtils::getSingleRootAlias($qb, $throwException); }
public function testGetSingleRootAliasWhenQueryHasNoRootAliasAndNoExceptionRequested() { $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $qb->expects($this->once())->method('getRootAliases')->willReturn([]); $this->assertNull(QueryUtils::getSingleRootAlias($qb, false)); }