source: branches/version-2/data/module/Calendar/tests/month_weeks_test.php @ 17143

Revision 17143, 3.6 KB checked in by adachi, 16 years ago (diff)

calendar bloc by Yammy (merge r17073, r17076, r17087, r17091)

Line 
1<?php
2// $Id: month_weeks_test.php,v 1.1 2004/05/24 22:25:43 quipo Exp $
3
4require_once('simple_include.php');
5require_once('calendar_include.php');
6
7require_once('./calendar_test.php');
8
9class TestOfMonthWeeks extends TestOfCalendar {
10    function TestOfMonthWeeks() {
11        $this->UnitTestCase('Test of Month Weeks');
12    }
13    function setUp() {
14        $this->cal = new Calendar_Month_Weeks(2003,10);
15    }
16    function testPrevDay () {
17        $this->assertEqual(30,$this->cal->prevDay());
18    }
19    function testPrevDay_Array () {
20        $this->assertEqual(
21            array(
22                'year'   => 2003,
23                'month'  => 9,
24                'day'    => 30,
25                'hour'   => 0,
26                'minute' => 0,
27                'second' => 0),
28            $this->cal->prevDay('array'));
29    }
30    function testThisDay () {
31        $this->assertEqual(1,$this->cal->thisDay());
32    }
33    function testNextDay () {
34        $this->assertEqual(2,$this->cal->nextDay());
35    }
36    function testPrevHour () {
37        $this->assertEqual(23,$this->cal->prevHour());
38    }
39    function testThisHour () {
40        $this->assertEqual(0,$this->cal->thisHour());
41    }
42    function testNextHour () {
43        $this->assertEqual(1,$this->cal->nextHour());
44    }
45    function testPrevMinute () {
46        $this->assertEqual(59,$this->cal->prevMinute());
47    }
48    function testThisMinute () {
49        $this->assertEqual(0,$this->cal->thisMinute());
50    }
51    function testNextMinute () {
52        $this->assertEqual(1,$this->cal->nextMinute());
53    }
54    function testPrevSecond () {
55        $this->assertEqual(59,$this->cal->prevSecond());
56    }
57    function testThisSecond () {
58        $this->assertEqual(0,$this->cal->thisSecond());
59    }
60    function testNextSecond () {
61        $this->assertEqual(1,$this->cal->nextSecond());
62    }
63    function testGetTimeStamp() {
64        $stamp = mktime(0,0,0,10,1,2003);
65        $this->assertEqual($stamp,$this->cal->getTimeStamp());
66    }
67}
68
69class TestOfMonthWeeksBuild extends TestOfMonthWeeks {
70    function TestOfMonthWeeksBuild() {
71        $this->UnitTestCase('Test of Month_Weeks::build()');
72    }
73    function testSize() {
74        $this->cal->build();
75        $this->assertEqual(5,$this->cal->size());
76    }
77
78    function testFetch() {
79        $this->cal->build();
80        $i=0;
81        while ( $Child = $this->cal->fetch() ) {
82            $i++;
83        }
84        $this->assertEqual(5,$i);
85    }
86/* Recusive dependency issue with SimpleTest
87    function testFetchAll() {
88        $this->cal->build();
89        $children = array();
90        $i = 1;
91        while ( $Child = $this->cal->fetch() ) {
92            $children[$i]=$Child;
93            $i++;
94        }
95        $this->assertEqual($children,$this->cal->fetchAll());
96    }
97*/
98    function testSelection() {
99        require_once(CALENDAR_ROOT . 'Week.php');
100        $selection = array(new Calendar_Week(2003, 10, 12));
101        $this->cal->build($selection);
102        $i = 1;
103        while ($Child = $this->cal->fetch()) {
104            if ($i == 2) {
105                break;  //12-10-2003 is the 2nd day of the week
106            }
107            $i++;
108        }
109        $this->assertTrue($Child->isSelected());
110    }
111    function testEmptyDaysBefore_AfterAdjust() {
112        $this->cal = new Calendar_Month_Weeks(2004,0);
113        $this->cal->build();
114        $this->assertEqual(0,$this->cal->tableHelper->getEmptyDaysBefore());
115    }
116}
117
118if (!defined('TEST_RUNNING')) {
119    define('TEST_RUNNING', true);
120    $test = &new TestOfMonthWeeks();
121    $test->run(new HtmlReporter());
122    $test = &new TestOfMonthWeeksBuild();
123    $test->run(new HtmlReporter());
124}
125?>
Note: See TracBrowser for help on using the repository browser.