#1001 DDC-3005 - Testing HydrationCompleteHandler
with multiple deferred entities postLoad
s
This commit is contained in:
parent
948d6c2b9f
commit
29d4d342bd
@ -60,6 +60,8 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider testGetValidListenerInvocationFlags
|
* @dataProvider testGetValidListenerInvocationFlags
|
||||||
|
*
|
||||||
|
* @param int $listenersFlag
|
||||||
*/
|
*/
|
||||||
public function testDefersPostLoadOfEntity($listenersFlag)
|
public function testDefersPostLoadOfEntity($listenersFlag)
|
||||||
{
|
{
|
||||||
@ -93,6 +95,48 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->handler->hydrationComplete();
|
$this->handler->hydrationComplete();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @dataProvider testGetValidListenerInvocationFlags
|
||||||
|
*
|
||||||
|
* @param int $listenersFlag
|
||||||
|
*/
|
||||||
|
public function testDefersMultiplePostLoadOfEntity($listenersFlag)
|
||||||
|
{
|
||||||
|
/* @var $metadata1 \Doctrine\ORM\Mapping\ClassMetadata */
|
||||||
|
/* @var $metadata2 \Doctrine\ORM\Mapping\ClassMetadata */
|
||||||
|
$metadata1 = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false);
|
||||||
|
$metadata2 = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false);
|
||||||
|
$entity1 = new stdClass();
|
||||||
|
$entity2 = new stdClass();
|
||||||
|
$entityManager = $this->entityManager;
|
||||||
|
|
||||||
|
$this
|
||||||
|
->listenersInvoker
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getSubscribedSystems')
|
||||||
|
->with($this->logicalOr($metadata1, $metadata2))
|
||||||
|
->will($this->returnValue($listenersFlag));
|
||||||
|
|
||||||
|
$this->handler->deferPostLoadInvoking($metadata1, $entity1);
|
||||||
|
$this->handler->deferPostLoadInvoking($metadata2, $entity2);
|
||||||
|
|
||||||
|
$this
|
||||||
|
->listenersInvoker
|
||||||
|
->expects($this->exactly(2))
|
||||||
|
->method('invoke')
|
||||||
|
->with(
|
||||||
|
$this->logicalOr($metadata1, $metadata2),
|
||||||
|
Events::postLoad,
|
||||||
|
$this->logicalOr($entity1, $entity2),
|
||||||
|
$this->callback(function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) {
|
||||||
|
return in_array($args->getEntity(), array($entity1, $entity2), true)
|
||||||
|
&& $entityManager === $args->getObjectManager();
|
||||||
|
}),
|
||||||
|
$listenersFlag
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->handler->hydrationComplete();
|
||||||
|
}
|
||||||
|
|
||||||
public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners()
|
public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user