Skip to content

Commit

Permalink
Added possibility to directly set the expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ancyrweb committed Nov 13, 2020
1 parent f1a8004 commit c3c9368
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Task/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public function getExpression() {
return $this->cron->getExpression();
}

/**
* @param string $value
*/
public function setExpression(string $value) {
$this->cron->setExpression($value);
return $this;
}

/**
* Return true if the schedule is due to now
* @param $currentTime
Expand Down
9 changes: 9 additions & 0 deletions Tests/Task/ScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,13 @@ public function testDaily() {
"1 2 * 4 5"
);
}
public function testSetExpression() {
$schedule = new Schedule("* * * * *");
$schedule->setExpression("0 * * * *");

$this->assertEquals(
$schedule->getExpression(),
"0 * * * *"
);
}
}

0 comments on commit c3c9368

Please sign in to comment.