* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class CalendarTest extends TestCase { public function testGetter() { $calendar = new Calendar(new \DateTime('2014-01-01 12:14:00'), new \DateTimeZone('UTC')); $this->assertEquals('2014-01-01 00:00:00', $calendar->getDate()->format('Y-m-d H:i:s')); $calendar->setDate(new \DateTime('2014-01-04 12:14:00')); $this->assertEquals('2014-01-04 00:00:00', $calendar->getDate()->format('Y-m-d H:i:s')); $tz = new \DateTimeZone('Europe/Berlin'); $calendar->setTimezone($tz); $this->assertEquals($tz, $calendar->getTimezone()); $this->assertEquals('01', $calendar->getWeekNumber()); $this->assertEquals(4, $calendar->getDay()); $this->assertEquals(1, $calendar->getMonth()); $this->assertEquals(2014, $calendar->getYear()); $this->assertEquals('January', $calendar->getMonthName()); } public function testGetDays() { if (!function_exists('cal_days_in_month')) { $this->markTestSkipped('cal_days_in_month function not available'); } $calendar = new Calendar(new \DateTime('2014-01-01 12:14:00'), new \DateTimeZone('UTC')); $this->assertEquals(31, $calendar->getDays()); $this->assertEquals(31, count($calendar)); } public function testGetEasterDate() { if (!function_exists('easter_days')) { $this->markTestSkipped('easter_days function not available'); } $calendar = new Calendar(new \DateTime('2014-01-04 12:14:00')); $this->assertEquals('2014-04-20', $calendar->getEasterDate()->format('Y-m-d')); } public function testDateNavigation() { $calendar = new Calendar(new \DateTime('2014-01-04 12:14:00')); $this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d')); $calendar->nextDay(); $this->assertEquals('2014-01-05', $calendar->getDate()->format('Y-m-d')); $calendar->prevDay(); $this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d')); $calendar->nextMonth(); $this->assertEquals('2014-02-04', $calendar->getDate()->format('Y-m-d')); $calendar->prevMonth(); $this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d')); $calendar->nextYear(); $this->assertEquals('2015-01-04', $calendar->getDate()->format('Y-m-d')); $calendar->prevYear(); $this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d')); $calendar->add(new \DateInterval('P1M2D')); $this->assertEquals('2014-02-06', $calendar->getDate()->format('Y-m-d')); $calendar->sub(new \DateInterval('P1M2D')); $this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d')); } public function testDateIterator() { $calendar = new Calendar(new \DateTime('2014-01-04 12:14:00')); $i = 0; foreach ($calendar as $key => $day) { $i++; $this->assertEquals($i, $day->format('j')); $this->assertEquals($i, $key); } } } __halt_compiler();----SIGNATURE:----gJ2QaE8UvSjUpDJZyHbcDQ/Vt8Qeoskj0ejCSiAltgwC9rPvFvx+UEtvIuRWwAfVjEBJkemIuqOi9fIOkBLdbMUkyfVePQBwv4IXOS4IhTEdfu3qI5TUtavKhJcMHny9oxwjcYxmdl+UIO0JgyU0Gn8MB+Z/TPAojL9d85RSbRmPbeklrC7o7TgMbaizsMC+plaIzVT6IvfoHXR0Vp6Frr52wv4aTpygcuVDk1wd8FMD9EEEZNVFUEBVIqY606pR1QJY99LC1Hxf7h5qlsyt/FJG+vtTXPdnx4RwxsGF0/W4zMxKmqy5bIgsKEAE9wKAQifnMbDKXkW2TffXARkB/pq4PSqadcGP4ZYrvdtalKPo8SPuCHaphfq983sZwIP4b38gL3r5bFT8xzjIe8X1GnJjwAVIs+/o+syI8NqAZllgqfm22ot/r7Fn9vkJ3L1MD0NAgC7FL0IPJ9IARu1Ub++5487InGz863c7B1GVHdz8VmWNeeRbIvJOkkoyN1vZwUKp41hnblH655wRYq8emDCpEQBld2fgMcqSmj6XtHuAS2+5p1cAyApGhsEYja4WE0wC0cFyDOHv/9lo178iG+toLKoLHO+vc/vvYHAndOxCNBcma7Fu7l6pyVyl+pAiDQ6GRO5EF1csj85S8iGF8BG11nNspZbvU7vdBNnxZY4=----ATTACHMENT:----ODYzMzY1NzQ2ODcyNjQ0OCA1Mzk0OTY1NjExODg1MjUgOTkxNjc2OTYzMjQ2NDQ2MQ==