コード例 #1
0
 public function testClone()
 {
     $schedule = new Schedule();
     $schedule->setScheduledAt(new \DateTime());
     $clone = clone $schedule;
     $this->assertNull($clone->getScheduledAt());
 }
コード例 #2
0
 /**
  * @param string|null $type
  * @param string|null $expression
  * @return Schedule
  */
 public static function createSchedule($type = null, $expression = null)
 {
     $schedule = new Schedule();
     $schedule->setType($type);
     $schedule->setExpression($expression);
     return $schedule;
 }
コード例 #3
0
 public function testProcessNotReturnsTrueTwiceWithinOneMinute()
 {
     $schedule = new Schedule();
     $schedule->setExpression('* * * * *');
     $schedule->setScheduledAt(new \DateTime('2010-01-01 00:00:00'));
     $this->factory->expects($this->any())->method('create')->with($schedule->getExpression())->will($this->returnValue($this->expression));
     $this->expression->expects($this->any())->method('isDue')->will($this->returnValue(true));
     $subject = new Processor(new ExpressionFactory());
     $this->assertFalse($subject->process($schedule, new \DateTime('2010-01-01 00:00:00')));
 }
コード例 #4
0
ファイル: TestJob.php プロジェクト: aboutcoders/job-bundle
 /**
  * Updates a schedule
  *
  * @ParamType("type", type="string")
  * @ParamType("expression", type="string")
  *
  * @param string $type
  * @param string $expression
  */
 public function updateSchedule($type, $expression)
 {
     $schedule = new Schedule();
     $schedule->setType($type);
     $schedule->setExpression($expression);
     $this->job->removeSchedules();
     $this->job->addSchedule($schedule);
 }
コード例 #5
0
ファイル: Schedule.php プロジェクト: aboutcoders/job-bundle
 /**
  * {@inheritDoc}
  */
 public function __clone()
 {
     parent::__clone();
     $this->createdAt = null;
     $this->updatedAt = null;
 }
コード例 #6
0
 private function createSchedules($num)
 {
     $schedules = array();
     for ($i = 0; $i < $num; $i++) {
         $schedule = new Schedule();
         $schedule->setType('type');
         $schedules[] = $schedule;
     }
     return $schedules;
 }
コード例 #7
0
 /**
  * @param \DateTime|null $currentDateTime
  * @dataProvider getDatesData
  */
 public function testProcessWithScheduledScheduleReturnsFalse(\DateTime $currentDateTime = null)
 {
     $schedule = new Schedule();
     $schedule->setScheduledAt(new \DateTime());
     $this->assertFalse($this->subject->process($schedule, $currentDateTime));
 }
コード例 #8
0
 public function testScheduleIsDisabledIfJobThrowsException()
 {
     // create scheduled job that throws an exception
     $schedule = new Schedule();
     $schedule->setExpression('* * * * *');
     $schedule->setType('cron');
     $ticket = $this->getJobManager()->addJob('throw_exception', array('message', 100), $schedule);
     // process schedules
     $this->runConsole("abc:scheduler:process", array("--iteration" => 1));
     $this->processJobs();
     $this->assertEquals(Status::ERROR(), $this->getJobManager()->get($ticket)->getStatus());
     $schedules = $this->getScheduleManager()->findSchedules();
     $this->assertCount(0, $schedules);
 }