/** * @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; }
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'))); }
/** * 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); }
/** * @param int $expression * @param boolean $isDue * @param \DateTime|null $currentDateTime * @dataProvider getExpectedData */ public function testProcessReturnsExpectedData($expression, $isDue, \DateTime $currentDateTime = null) { $schedule = new Schedule(); $schedule->setExpression($expression); $this->assertEquals($isDue, $this->subject->process($schedule, $currentDateTime)); }
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); }