Exemple #1
0
 public function testFlushMessage()
 {
     $transport = $this->getMock('\\Swift_Transport');
     $transport->expects($this->once())->method('isStarted')->will($this->returnValue(false));
     $transport->expects($this->once())->method('start');
     $message = $this->getMock('\\Swift_Mime_Message');
     $spoolItem = $this->getMock(self::SPOOL_ITEM_CLASS);
     $spoolItem->expects($this->once())->method('setStatus');
     $spoolItem->expects($this->once())->method('getMessage')->will($this->returnValue($message));
     $emails = array($spoolItem);
     $this->em->expects($this->once())->method('persist')->with($this->isInstanceOf(self::SPOOL_ITEM_CLASS));
     $this->em->expects($this->exactly(2))->method('flush');
     $this->em->expects($this->once())->method('remove');
     $repository = $this->getMockBuilder('Oro\\Bundle\\NotificationBundle\\Entity\\Repository\\SpoolItemRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findBy')->will($this->returnValue($emails));
     $this->em->expects($this->once())->method('getRepository')->with(self::SPOOL_ITEM_CLASS)->will($this->returnValue($repository));
     $transport->expects($this->once())->method('send')->with($message, array())->will($this->returnValue(1));
     $this->spool->setTimeLimit(-100);
     $count = $this->spool->flushQueue($transport);
     $this->assertEquals(1, $count);
 }