Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 1
<?php
2
// $Id: month_weekdays_test.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
3
 
4
require_once('simple_include.php');
5
require_once('calendar_include.php');
6
 
7
require_once('./calendar_test.php');
8
 
9
class TestOfMonthWeekdays extends TestOfCalendar {
10
    function TestOfMonthWeekdays() {
11
        $this->UnitTestCase('Test of Month Weekdays');
12
    }
13
    function setUp() {
14
        $this->cal = new Calendar_Month_Weekdays(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
 
69
class TestOfMonthWeekdaysBuild extends TestOfMonthWeekdays {
70
    function TestOfMonthWeekdaysBuild() {
71
        $this->UnitTestCase('Test of Month_Weekdays::build()');
72
    }
73
    function testSize() {
74
        $this->cal->build();
75
        $this->assertEqual(35,$this->cal->size());
76
    }
77
    function testFetch() {
78
        $this->cal->build();
79
        $i=0;
80
        while ( $Child = $this->cal->fetch() ) {
81
            $i++;
82
        }
83
        $this->assertEqual(35,$i);
84
    }
85
    function testFetchAll() {
86
        $this->cal->build();
87
        $children = array();
88
        $i = 1;
89
        while ( $Child = $this->cal->fetch() ) {
90
            $children[$i]=$Child;
91
            $i++;
92
        }
93
        $this->assertEqual($children,$this->cal->fetchAll());
94
    }
95
    function testSelection() {
96
        require_once(CALENDAR_ROOT . 'Day.php');
97
        $selection = array(new Calendar_Day(2003,10,25));
98
        $this->cal->build($selection);
99
        $i = 1;
100
        while ( $Child = $this->cal->fetch() ) {
101
            if ( $i == 27 )
102
                break;
103
            $i++;
104
        }
105
        $this->assertTrue($Child->isSelected());
106
    }
107
    function testEmptyCount() {
108
        $this->cal->build();
109
        $empty = 0;
110
        while ( $Child = $this->cal->fetch() ) {
111
            if ( $Child->isEmpty() )
112
                $empty++;
113
        }
114
        $this->assertEqual(4,$empty);
115
    }
116
    function testEmptyDaysBefore_AfterAdjust() {
117
        $this->cal = new Calendar_Month_Weekdays(2004,0);
118
        $this->cal->build();
119
        $this->assertEqual(0,$this->cal->tableHelper->getEmptyDaysBefore());
120
    }
121
}
122
 
123
if (!defined('TEST_RUNNING')) {
124
    define('TEST_RUNNING', true);
125
    $test = &new TestOfMonthWeekdays();
126
    $test->run(new HtmlReporter());
127
     $test = &new TestOfMonthWeekdaysBuild();
128
    $test->run(new HtmlReporter());
129
}
130
?>