コード例 #1
0
 /**
  * @covers Kunstmaan\PagePartBundle\EventListener\CloneListener::postDeepCloneAndSave
  */
 public function testClonePageTemplate()
 {
     $entity = $this->getMockBuilder('Kunstmaan\\PagePartBundle\\Helper\\HasPageTemplateInterface')->setMethods(array('getId', 'getPageTemplates', 'getPagePartAdminConfigurations'))->getMock();
     $entity->expects($this->any())->method('getPagePartAdminConfigurations')->will($this->returnValue(array($this->configurator)));
     $clone = clone $entity;
     $entity->expects($this->any())->method('getId')->will($this->returnValue(1));
     $clone->expects($this->any())->method('getId')->will($this->returnValue(2));
     $this->repo->expects($this->once())->method('copyPageParts')->with($this->em, $entity, $clone, 'main');
     $configuration = new PageTemplateConfiguration();
     $configuration->setId(1);
     $configuration->setPageId(1);
     $this->repo->expects($this->once())->method('findOrCreateFor')->with($this->identicalTo($entity))->will($this->returnValue($configuration));
     $newConfiguration = clone $configuration;
     $newConfiguration->setId(null);
     $newConfiguration->setPageId($clone->getId());
     $this->em->expects($this->once())->method('persist')->with($newConfiguration);
     $event = new DeepCloneAndSaveEvent($entity, $clone);
     $this->object->postDeepCloneAndSave($event);
 }
コード例 #2
0
 /**
  * @covers Kunstmaan\PagePartBundle\EventListener\CloneListener::postDeepCloneAndSave
  */
 public function testClonePageTemplate()
 {
     $entity = $this->getMock(HasPageTemplateInterface::class);
     /** @var HasPageTemplateInterface|\PHPUnit_Framework_MockObject_MockObject $clone */
     $clone = clone $entity;
     $entity->expects($this->any())->method('getId')->will($this->returnValue(1));
     $clone->expects($this->any())->method('getId')->will($this->returnValue(2));
     $this->repo->expects($this->once())->method('copyPageParts')->with($this->em, $entity, $clone, 'main');
     $configuration = new PageTemplateConfiguration();
     $configuration->setId(1);
     $configuration->setPageId(1);
     $this->templateService->expects($this->once())->method('findOrCreateFor')->with($this->identicalTo($entity))->will($this->returnValue($configuration));
     $newConfiguration = clone $configuration;
     $newConfiguration->setId(null);
     $newConfiguration->setPageId($clone->getId());
     $this->em->expects($this->once())->method('persist')->with($newConfiguration);
     $event = new DeepCloneAndSaveEvent($entity, $clone);
     $this->object->postDeepCloneAndSave($event);
 }