1
0
mirror of synced 2025-01-30 20:11:49 +03:00

[DDC-991] Rename method to AbstractQuery::getOneOrNullResult().

This commit is contained in:
Benjamin Eberlei 2011-03-31 23:35:01 +02:00
parent 24a7a72f59
commit ea52b3cc8f
2 changed files with 9 additions and 9 deletions

View File

@ -420,7 +420,7 @@ abstract class AbstractQuery
* @param int $hydrationMode
* @return mixed
*/
public function getOneResult($hydrationMode = null)
public function getOneOrNullResult($hydrationMode = null)
{
$result = $this->execute(array(), $hydrationMode);

View File

@ -382,7 +382,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
/**
* @group DDC-991
*/
public function testGetOneResult()
public function testgetOneOrNullResult()
{
$user = new CmsUser;
$user->name = 'Guilherme';
@ -394,19 +394,19 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$fetchedUser = $query->getOneResult();
$fetchedUser = $query->getOneOrNullResult();
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $fetchedUser);
$this->assertEquals('gblanco', $fetchedUser->username);
$query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$fetchedUsername = $query->getOneResult(Query::HYDRATE_SINGLE_SCALAR);
$fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR);
$this->assertEquals('gblanco', $fetchedUsername);
}
/**
* @group DDC-991
*/
public function testGetOneResultSeveralRows()
public function testgetOneOrNullResultSeveralRows()
{
$user = new CmsUser;
$user->name = 'Guilherme';
@ -424,18 +424,18 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u");
$this->setExpectedException('Doctrine\ORM\NonUniqueResultException');
$fetchedUser = $query->getOneResult();
$fetchedUser = $query->getOneOrNullResult();
}
/**
* @group DDC-991
*/
public function testGetOneResultNoRows()
public function testgetOneOrNullResultNoRows()
{
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u");
$this->assertNull($query->getOneResult());
$this->assertNull($query->getOneOrNullResult());
$query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$this->assertNull($query->getOneResult(Query::HYDRATE_SCALAR));
$this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR));
}
}