* @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:----AiJ1y/9tvb89PgVXu2ulKJO02vO26rFvCmapae1vk1ik6jVW1DHlnf9XjnrpU7EC+Jrl9CWo1ZwpvqBIW+WJqAvxrWs7BkNgb09lLRH15toKzVzF6Y7AS0nGIY7JGBSGc8foVhVqCs9ysJ/zyHSPVLULeJo7SadAGO0qJxS64tYxYO8cADo90JO9ljo4RT1cEl1jc1hJhAuWjZT4ybwvFjqFsrw95FvjXesxKKsSBDvZInO8G4cOt/ZO6g4gaP1FhUOPJmwtqZZaf6EOIDDlwE9RqgyGKxWHKGM4vBhlwwsrBuqmlrTwxZG46WZeHlMtpMXKCxwBqScuE20KTca6lHqBCNGbkOwvYAEINee0ZfIuGWf5RURxdwEebID9VP4jeXaK9JhLg8gimoN+MPzo0VuEI17KkkWBtUoZvAuPCZXAP0FFe/zhLn7lbupfQwHs58VPRurUyGWxDZKXQU6Lwokod33QGPQaq16v7U+tIDLVE6zKNnkLq3GOD7vpQEiPeYdpLCPgjpixjjG4mC2V5x3OXmueonpdg0qKh3OjpfrqIkMVKvyjTrypgmspEBynodNk7P+LAblFnt2Jpk9PeA4SkW0rYkTJGWMpdjLgVpCjA0B4PKWSEsnzGUP8rR/huiiu5YOismB8R9lhJ2kyPf8OjeRHsYDc4OSpOOTnLec=----ATTACHMENT:----NTkyNTE0NTM3OTIyNTczNiA5OTMwNzc0MTQyNzQ2OTQxIDQzMjYxNzIzMDgzNTM4NjA=