1
0
mirror of synced 2025-03-21 15:33:51 +03:00

#470 DDC-54 DDC-3005 - minor test cleanups, changing test according to current limitation to document the actual expected behavior

This commit is contained in:
Marco Pivetta 2015-01-13 01:26:04 +01:00
parent a884452ffc
commit 0a19fbb376

View File

@ -150,6 +150,10 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertTrue($e2->prePersistCallbackInvoked); $this->assertTrue($e2->prePersistCallbackInvoked);
} }
/**
* @group DDC-54
* @group DDC-3005
*/
public function testCascadedEntitiesLoadedInPostLoad() public function testCascadedEntitiesLoadedInPostLoad()
{ {
$e1 = new LifecycleCallbackTestEntity(); $e1 = new LifecycleCallbackTestEntity();
@ -166,12 +170,21 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery(' $dql = <<<'DQL'
SELECT e, c SELECT
FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e e, c
LEFT JOIN e.cascader AS c FROM
WHERE e.id IN ('.$e1->getId().', '.$e2->getId().')'); Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e
$entities = $query->execute(null, \Doctrine\ORM\Query::HYDRATE_OBJECT); LEFT JOIN
e.cascader AS c
WHERE
e.id IN (%s, %s)
DQL;
$entities = $this
->_em
->createQuery(sprintf($dql, $e1->getId(), $e2->getId()))
->getResult();
$this->assertTrue(current($entities)->postLoadCallbackInvoked); $this->assertTrue(current($entities)->postLoadCallbackInvoked);
$this->assertTrue(current($entities)->postLoadCascaderNotNull); $this->assertTrue(current($entities)->postLoadCascaderNotNull);
@ -179,6 +192,10 @@ WHERE e.id IN ('.$e1->getId().', '.$e2->getId().')');
$this->assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); $this->assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2);
} }
/**
* @group DDC-54
* @group DDC-3005
*/
public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration() public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration()
{ {
$e1 = new LifecycleCallbackTestEntity(); $e1 = new LifecycleCallbackTestEntity();
@ -195,16 +212,29 @@ WHERE e.id IN ('.$e1->getId().', '.$e2->getId().')');
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery(' $dql = <<<'DQL'
SELECT e, c SELECT
FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e e, c
LEFT JOIN e.cascader AS c FROM
WHERE e.id IN ('.$e1->getId().', '.$e2->getId().')'); Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e
$result = $query->iterate(); LEFT JOIN
e.cascader AS c
WHERE
e.id IN (%s, %s)
DQL;
$result = $this
->_em
->createQuery(sprintf($dql, $e1->getId(), $e2->getId()))
->iterate();
foreach ($result as $entity) { foreach ($result as $entity) {
$this->assertTrue($entity[0]->postLoadCallbackInvoked); $this->assertFalse(
$entity[0]->postLoadCallbackInvoked,
'During iteration, postLoad callbacks are not triggered until the end of the resultset is reached'
);
$this->assertFalse($entity[0]->postLoadCascaderNotNull); $this->assertFalse($entity[0]->postLoadCascaderNotNull);
break; break;
} }
} }