Skip to content

Commit c3c9368

Browse files
committed
Added possibility to directly set the expression
1 parent f1a8004 commit c3c9368

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Task/Schedule.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public function getExpression() {
107107
return $this->cron->getExpression();
108108
}
109109

110+
/**
111+
* @param string $value
112+
*/
113+
public function setExpression(string $value) {
114+
$this->cron->setExpression($value);
115+
return $this;
116+
}
117+
110118
/**
111119
* Return true if the schedule is due to now
112120
* @param $currentTime

Tests/Task/ScheduleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ public function testDaily() {
7070
"1 2 * 4 5"
7171
);
7272
}
73+
public function testSetExpression() {
74+
$schedule = new Schedule("* * * * *");
75+
$schedule->setExpression("0 * * * *");
76+
77+
$this->assertEquals(
78+
$schedule->getExpression(),
79+
"0 * * * *"
80+
);
81+
}
7382
}

0 commit comments

Comments
 (0)