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()); }
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()); } }
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)); }
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')); } }
/** * @dataProvider providerGetFirstMondayAndLastSunday */ public function testFindFirstDayOfWeek(Month $month, $firstDay) { $this->assertSame($firstDay, $this->getDefaultOptionsFactory()->findFirstDayOfWeek($month->getBegin())->format('Y-m-d')); }