Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function isDue($date = 'now')
 {
     if (!$date instanceof \DateTime) {
         $date = new \DateTime($date);
     }
     return $this->expression->matches($date);
 }
Exemplo n.º 2
0
 /**
  * @covers CronExpression::__construct
  * @covers CronExpression::matches
  * @covers CronExpression::setExpression
  */
 public function testMatches()
 {
     $validMatches = array('* * * * *' => 'now', '0 0 ? */2 FRI#2 *' => 'june 14th 2013');
     foreach ($validMatches as $value => $date) {
         $expression = new CronExpression($value);
         $this->assertTrue($expression->matches(new \DateTime($date)), "{$value} does not match {$date}");
     }
     $invalidMatches = array('1 * * * *' => 'midnight');
     foreach ($invalidMatches as $value => $date) {
         $expression = new CronExpression($value);
         $this->assertFalse($expression->matches(new \DateTime($date)), "{$value} matches {$date}");
     }
 }