Beispiel #1
0
 function testWeekModule()
 {
     $days = array();
     for ($i = 6; $i < 13; $i++) {
         $days[] = new RMHDate(date('y-m-d', mktime(0, 0, 0, 2, $i, 2012)), "house", array(), "");
     }
     $aweek = new Week($days, "house", "archived");
     $this->assertEqual($aweek->get_name(), "February 6, 2012 to February 12, 2012");
     $this->assertEqual($aweek->get_id(), "12-02-06:house");
     $this->assertTrue(sizeof($aweek->get_dates()) == 7);
     $this->assertEqual($aweek->get_venue(), "house");
     $this->assertEqual($aweek->get_status(), "archived");
     $this->assertEqual($aweek->get_end(), mktime(23, 59, 59, 2, 12, 2012));
     echo "testWeek complete";
 }
 function testWeekModule()
 {
     $today = date('y-m-d');
     $timestamp = mktime(0, 0, 0, substr($today, 3, 2), substr($today, 6, 2), substr($today, 0, 2));
     $dayofweek = date("N", $timestamp);
     $mondaymm = date("m", mktime(0, 0, 0, substr($today, 3, 2), substr($today, 6, 2) - $dayofweek + 1, substr($today, 0, 2)));
     $mondaydd = date("d", mktime(0, 0, 0, substr($today, 3, 2), substr($today, 6, 2) - $dayofweek + 1, substr($today, 0, 2)));
     $mondayyy = date("y", mktime(0, 0, 0, substr($today, 3, 2), substr($today, 6, 2) - $dayofweek + 1, substr($today, 0, 2)));
     $roomlogs = new ArrayObject();
     for ($d = $mondaydd; $d < $mondaydd + 7; $d++) {
         $day_id = date("y-m-d", mktime(0, 0, 0, $mondaymm, $d, $mondayyy));
         $roomlogs[] = new RoomLog($day_id);
     }
     $w = new Week($roomlogs);
     $mon = $roomlogs[0];
     $sun = $roomlogs[6];
     $this->assertTrue($w->get_id() == $mon->get_id());
     $this->assertTrue(sizeof($w->get_roomlogs()) == 7);
     $this->assertTrue($w->get_name() == $mon->get_name() . " to " . $sun->get_name());
     $this->assertTrue($w->get_end() == $sun->get_end_time());
     $this->assertTrue(true);
     echo $mon->get_name() . " to " . $sun->get_name() . "\n";
     echo "testWeek complete";
 }
/**
 * Use this method to sanity-check a Week object before it is inserted into the database
 * @param Week $w The week object to check
 *
 * @return bool true only if the week starts on a Sunday and has a length of 7 days, otherwise return false
 */
function assert_week_format(Week $w)
{
    $date = DateTime::createFromFormat("m-d-y", $w->get_id());
    $dow = $date->format("w");
    return $dow == 0 && count($w->get_dates()) == 7;
}