public function testClone() { $schedule = new Schedule(); $schedule->setScheduledAt(new \DateTime()); $clone = clone $schedule; $this->assertNull($clone->getScheduledAt()); }
/** * @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); }
/** * {@inheritDoc} */ public function __clone() { parent::__clone(); $this->createdAt = null; $this->updatedAt = null; }
private function createSchedules($num) { $schedules = array(); for ($i = 0; $i < $num; $i++) { $schedule = new Schedule(); $schedule->setType('type'); $schedules[] = $schedule; } return $schedules; }
/** * @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)); }
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); }