Added a test case for postLoad on fetch-joined entities
see https://github.com/doctrine/doctrine2/issues/6568
This commit is contained in:
parent
63519be69c
commit
c47cf1de34
@ -269,6 +269,47 @@ DQL;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/doctrine/doctrine2/issues/6568
|
||||||
|
*/
|
||||||
|
public function testPostLoadIsInvokedOnFetchJoinedEntities()
|
||||||
|
{
|
||||||
|
$entA = new LifecycleCallbackCascader();
|
||||||
|
$this->_em->persist($entA);
|
||||||
|
|
||||||
|
$entB_1 = new LifecycleCallbackTestEntity();
|
||||||
|
$entB_2 = new LifecycleCallbackTestEntity();
|
||||||
|
|
||||||
|
$entA->entities[] = $entB_1;
|
||||||
|
$entA->entities[] = $entB_2;
|
||||||
|
$entB_1->cascader = $entA;
|
||||||
|
$entB_2->cascader = $entA;
|
||||||
|
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$dql = <<<'DQL'
|
||||||
|
SELECT
|
||||||
|
entA, entB
|
||||||
|
FROM
|
||||||
|
Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader AS entA
|
||||||
|
LEFT JOIN
|
||||||
|
entA.entities AS entB
|
||||||
|
WHERE
|
||||||
|
entA.id = %s
|
||||||
|
DQL;
|
||||||
|
|
||||||
|
$fetchedA = $this
|
||||||
|
->_em
|
||||||
|
->createQuery(sprintf($dql, $entA->getId()))
|
||||||
|
->getOneOrNullResult();
|
||||||
|
|
||||||
|
$this->assertTrue($fetchedA->postLoadCallbackInvoked);
|
||||||
|
foreach ($fetchedA->entities as $fetchJoinedEntB) {
|
||||||
|
$this->assertTrue($fetchJoinedEntB->postLoadCallbackInvoked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testLifecycleCallbacksGetInherited()
|
public function testLifecycleCallbacksGetInherited()
|
||||||
{
|
{
|
||||||
$childMeta = $this->_em->getClassMetadata(LifecycleCallbackChildEntity::class);
|
$childMeta = $this->_em->getClassMetadata(LifecycleCallbackChildEntity::class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user