onFlush() public method

public onFlush ( Doctrine\ORM\Event\OnFlushEventArgs $args ) : mixed | void
$args Doctrine\ORM\Event\OnFlushEventArgs
return mixed | void
Ejemplo n.º 1
0
 /**
  * postUpdate with Page and 10 children
  */
 public function testPostUpdate_WithPageAndTenChildren()
 {
     $container = $this->getMock('\\Symfony\\Component\\DependencyInjection\\Container');
     $pageListener = new PageListener(new \Symfony\Component\HttpFoundation\Session\Session(), $container);
     // contentRoute
     $contentRoute = $this->getMock('\\Networking\\InitCmsBundle\\Model\\ContentRoute', array('setPath'));
     $contentRoute->expects($this->once())->method('setPath')->with($this->equalTo('/'));
     // entity
     $entity = $this->getMock('\\Networking\\InitCmsBundle\\Model\\Page');
     $entity->expects($this->once())->method('getContentRoute')->will($this->returnValue($contentRoute));
     $entity->expects($this->once())->method('getAllChildren')->will($this->returnValue($this->getMockChildren(10)));
     // em
     $em = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $uow = $this->getMockBuilder('\\Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow));
     $classMetaData = $this->getMockBuilder('\\Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $em->expects($this->exactly(11))->method('getClassMetadata')->will($this->returnValue($classMetaData));
     $em->expects($this->exactly(11))->method('persist');
     $uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue(array($entity)));
     $uow->expects($this->exactly(11))->method('computeChangeSet');
     $args = $this->getMockBuilder('\\Doctrine\\ORM\\Event\\OnFlushEventArgs')->disableOriginalConstructor()->getMock();
     // args methods:
     // getEntityManager
     $args->expects($this->once())->method('getEntityManager')->will($this->returnValue($em));
     $pageListener->onFlush($args);
 }