Example #1
0
 public function testFindBy()
 {
     $result = array(1, 2, 4);
     $criteria = array('resource' => 'article');
     $orderBy = array('created');
     $limit = 5;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with($this->equalTo($criteria), $this->equalTo($orderBy), $this->equalTo($limit), $this->equalTo($offset))->will($this->returnValue($result));
     $this->em->expects($this->once())->method('getRepository')->with($this->equalTo('Newscoop\\Entity\\AuditEvent'))->will($this->returnValue($this->repository));
     $this->assertEquals($result, $this->service->findBy($criteria, $orderBy, $limit, $offset));
 }
 /**
  * @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);
 }