public function testDatesInMonth() { // Get month which don't hold todays date. $el = new \Fnlive\Calendar\CCalendar("2015-03-08"); $res = $el->datesInMonth(); // Set subset of expected monthly dates $exp = [9 => ["week" => "10", "date" => "04 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 10 => ["week" => "10", "date" => "05 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 11 => ["week" => "10", "date" => "06 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 12 => ["week" => "10", "date" => "07 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 13 => ["week" => "10", "date" => "08 Mar", "class-red" => "red-day", "class-today" => "", "class-in-month" => "class-inside-month"], 14 => ["week" => "11", "date" => "09 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 15 => ["week" => "11", "date" => "10 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"], 16 => ["week" => "11", "date" => "11 Mar", "class-red" => "", "class-today" => "", "class-in-month" => "class-inside-month"]]; for ($i = 9; $i < 17; $i++) { $this->assertEquals($res[$i], $exp[$i], "Date missmatch."); } // Assert two date outside of current month $exp = [38 => ["week" => "14", "date" => "02 Apr", "class-red" => "", "class-today" => "", "class-in-month" => "class-outside-month"]]; $this->assertEquals($res[38], $exp[38], "Date missmatch."); $exp = [1 => ["week" => "9", "date" => "24 Feb", "class-red" => "", "class-today" => "", "class-in-month" => "class-outside-month"]]; $this->assertEquals($res[1], $exp[1], "Date missmatch."); // echo "<br>" . __FILE__ . " : " . __LINE__ . "<br>";var_dump($res); }
<?php /** * This is a Anax pagecontroller. * */ // Get environment & autoloader and the $app-object. require __DIR__ . '/config.php'; // Create services and inject into the app. $di = new \Anax\DI\CDIFactory(); $app = new \Anax\MVC\CApplicationBasic($di); $app->theme->configure(ANAX_APP_PATH . 'config/theme_me.php'); // On production server, set pretty urls and use rewrite in .htaccess $app->url->setUrlType($_SERVER['SERVER_NAME'] == 'localhost' ? \Anax\Url\CUrl::URL_APPEND : \Anax\Url\CUrl::URL_CLEAN); $app->router->add('', function () use($app) { $app->theme->setTitle("Calendar test"); $app->views->add('default/page', ['title' => "Testing calendar portal", 'content' => "Page for testing calendar. Click below link for calendar.", 'links' => [['href' => $app->url->create('calendar'), 'text' => "Calendar"]]]); }); // Route to calendar $app->router->add('calendar', function () use($app) { $app->theme->addStylesheet('css/calendar.css'); $app->theme->setTitle("Calendar"); $today = new DateTime(); $date = $app->request->getGet('date', $today->format('Y-m-d')); $calendar = new \Fnlive\Calendar\CCalendar($date); $app->views->add('calendar/index', ['prevMonth' => $calendar->prevMonth(), 'nextMonth' => $calendar->nextMonth(), 'prevMonthDate' => $calendar->prevMonthDate(), 'nextMonthDate' => $calendar->nextMonthDate(), 'thisMonth' => $calendar->thisMonth(), 'dates' => $calendar->datesInMonth()]); }); $app->router->handle(); // Render the response using theme engine. $app->theme->render();