Example #1
0
 /**
  * Test on updated propose update task.
  */
 public function testOnUpdatedProposeUpdateTask()
 {
     $that = $this;
     $next_run = new \DateTime();
     $next_run->modify('+' . ProposeUpdateCommand::INERVAL_UPDATE . ' seconds  01:00:00');
     $task = $this->getMock('\\AnimeDb\\Bundle\\AppBundle\\Entity\\Task');
     $task->expects($this->once())->method('setNextRun')->will($this->returnCallback(function ($date) use($that, $next_run, $task) {
         $that->assertEquals($next_run, $date);
         return $task;
     }));
     $rep = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMockForAbstractClass();
     $rep->expects($this->any())->method('findOneBy')->will($this->returnValue($task))->with(['command' => 'animedb:propose-update']);
     $this->em->expects($this->once())->method('getRepository')->with('AnimeDbAppBundle:Task')->will($this->returnValue($rep));
     $this->em->expects($this->once())->method('persist')->with($task);
     $this->em->expects($this->once())->method('flush');
     // test
     $this->listener->onUpdatedProposeUpdateTask();
 }