Exemple #1
0
 public function testIteration()
 {
     $start = new \DateTime('2012-01-01');
     $month = new Month($start);
     $i = 0;
     foreach ($month as $week) {
         $this->assertInstanceOf('CalendR\\Period\\Week', $week);
         foreach ($week as $day) {
             if ($month->contains($day->getBegin())) {
                 $this->assertSame($start->format('d-m-Y'), $day->getBegin()->format('d-m-Y'));
                 $start->add(new \DateInterval('P1D'));
                 $i++;
             }
         }
     }
     $this->assertEquals($i, 31);
 }
Exemple #2
0
 public function testIsCurrent()
 {
     $currentDate = new \DateTime();
     $otherDate = clone $currentDate;
     $otherDate->add(new \DateInterval('P5M'));
     $currentMonth = new Month(new \DateTime(date('Y-m') . '-01'), $this->prophesize(FactoryInterface::class)->reveal());
     $otherMonth = $currentMonth->getNext();
     $this->assertTrue($currentMonth->contains($currentDate));
     $this->assertFalse($currentMonth->contains($otherDate));
     $this->assertFalse($otherMonth->contains($currentDate));
 }
 public function testIsCurrent()
 {
     $currentDate = new \DateTime();
     $otherDate = clone $currentDate;
     $otherDate->add(new \DateInterval('P5M'));
     $currentMonth = new Month(new \DateTime(date('Y-m') . '-01'));
     $otherMonth = $currentMonth->getNext();
     $this->assertTrue($currentMonth->contains($currentDate));
     $this->assertFalse($currentMonth->contains($otherDate));
     $this->assertFalse($otherMonth->contains($currentDate));
 }