Exemple #1
0
 public function testCombinedRules()
 {
     $start = Carbon::now();
     $recur = Recur::create($start)->every(14, "daysOfMonth")->every("February", "monthsOfYear");
     $this->assertTrue($recur->matches(Carbon::parse("February 14")->addYear(1)));
     $this->assertFalse($recur->matches($start));
 }
Exemple #2
0
 public function testNoMatchException()
 {
     $start = Carbon::parse($this->start_date);
     $exception = $start->copy()->addDays(7);
     $recur = Recur::create($start)->every(1, "weeks");
     $this->assertTrue($recur->matches($exception));
     $recur->except($exception);
     $this->assertFalse($recur->matches($exception));
 }
Exemple #3
0
 public function testYearly()
 {
     $config = ["start" => "2015-01-01", "timezone" => "America/Phoenix", "exceptions" => [], "rules" => ["years" => ["measure" => "years", "units" => ["1" => true]]]];
     $recur = Recur::create($config);
     $nextDates = $recur->next(3);
     $this->assertEquals(3, count($nextDates));
     $this->assertEquals($nextDates[0], "2016-01-01");
     $this->assertEquals($nextDates[1], "2017-01-01");
     $this->assertEquals($nextDates[2], "2018-01-01");
 }
Exemple #4
0
 public function testMultipleIntervals()
 {
     $start = Carbon::parse($this->start_date);
     $recur = Recur::create($start)->every([3, 5], "days");
     $this->assertTrue($recur->matches($start->copy()->addDays(3)));
     $this->assertTrue($recur->matches($start->copy()->addDays(5)));
     $this->assertTrue($recur->matches($start->copy()->addDays(10)));
     $this->assertFalse($recur->matches($start->copy()->addDays(4)));
     $this->assertFalse($recur->matches($start->copy()->addDays(8)));
 }
Exemple #5
0
 public function testRecurAssignEndParameter()
 {
     $recur = new Recur();
     $recur->end($this->end_date);
     $this->assertEquals($recur->end->toDateString(), $this->end_date);
 }
Exemple #6
0
 public function testNoRepeatWithNoRules()
 {
     $recur = Recur::now();
     $this->assertFalse($recur->repeats());
 }
Exemple #7
0
 public function testWeekStartFromError()
 {
     $config = ['start' => '2015-04-02', 'from' => '2015-04-19', 'timezone' => 'America/Phoenix', 'exceptions' => [], 'rules' => ['daysOfWeek' => ['measure' => 'daysOfWeek', 'units' => ['4' => 1]], 'weeks' => ['measure' => 'weeks', 'units' => ['2' => 1]]]];
     $recur = Recur::create($config);
     $nextDates = $recur->next(3);
     $this->assertEquals(count($nextDates), 3);
     $this->assertEquals($nextDates[0], "2015-04-30");
     $this->assertEquals($nextDates[1], "2015-05-14");
 }
Exemple #8
0
 public function testUnitsPropertyArray()
 {
     $recur = Recur::now()->every([1, 2]);
     $this->assertNotNull($recur::$units);
 }
Exemple #9
0
 public function testForgetRule()
 {
     $recur = Recur::create("01/01/2014")->every(1, "day");
     $recur->forget("days");
     $this->assertEquals(count($recur->rules), 0);
 }