예제 #1
0
 public function testMonth()
 {
     $month = new Month(new \DateTime('2013-01-01'), new Factory($this->options));
     foreach ($month as $week) {
         $this->assertInstanceOf('CalendR\\Test\\Fixtures\\Period\\Week', $week);
     }
     $days = $month->getDays();
     $this->assertInstanceOf('CalendR\\Test\\Fixtures\\Period\\Day', $days[0]);
     $this->assertInstanceOf('CalendR\\Test\\Fixtures\\Period\\Range', $month->getExtendedMonth());
 }
예제 #2
0
 public function testMonthTransmitToWeek()
 {
     $month = new Month(new \DateTime('2013-01-01'), Day::SUNDAY);
     $this->assertSame(Day::SUNDAY, $month->getPrevious()->getFirstWeekday());
     $this->assertSame(Day::SUNDAY, $month->getNext()->getFirstWeekday());
     $this->assertSame(Day::SUNDAY, $month->getExtendedMonth()->getFirstWeekday());
     foreach ($month as $week) {
         $this->assertSame(Day::SUNDAY, $week->getFirstWeekday());
     }
 }
예제 #3
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));
 }
예제 #4
0
 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));
 }
예제 #5
0
 public function testGetDatePeriod()
 {
     $date = new \DateTime('2012-01-01');
     $month = new Month($date);
     foreach ($month->getDatePeriod() as $dateTime) {
         $this->assertEquals($date->format('Y-m-d'), $dateTime->format('Y-m-d'));
         $date->add(new \DateInterval('P1D'));
     }
 }
예제 #6
0
 /**
  * @dataProvider providerGetFirstMondayAndLastSunday
  */
 public function testFindFirstDayOfWeek(Month $month, $firstDay)
 {
     $this->assertSame($firstDay, $this->getDefaultOptionsFactory()->findFirstDayOfWeek($month->getBegin())->format('Y-m-d'));
 }