Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 1
<?php
2
// $Id: year_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 TestOfYear extends TestOfCalendar {
10
    function TestOfYear() {
11
        $this->UnitTestCase('Test of Year');
12
    }
13
    function setUp() {
14
        $this->cal = new Calendar_Year(2003);
15
    }
16
    function testPrevYear_Object() {
17
        $this->assertEqual(new Calendar_Year(2002), $this->cal->prevYear('object'));
18
    }
19
    function testThisYear_Object() {
20
        $this->assertEqual(new Calendar_Year(2003), $this->cal->thisYear('object'));
21
    }
22
    function testPrevMonth () {
23
        $this->assertEqual(12,$this->cal->prevMonth());
24
    }
25
    function testPrevMonth_Array () {
26
        $this->assertEqual(
27
            array(
28
                'year'   => 2002,
29
                'month'  => 12,
30
                'day'    => 1,
31
                'hour'   => 0,
32
                'minute' => 0,
33
                'second' => 0),
34
            $this->cal->prevMonth('array'));
35
    }
36
    function testThisMonth () {
37
        $this->assertEqual(1,$this->cal->thisMonth());
38
    }
39
    function testNextMonth () {
40
        $this->assertEqual(2,$this->cal->nextMonth());
41
    }
42
    function testPrevDay () {
43
        $this->assertEqual(31,$this->cal->prevDay());
44
    }
45
    function testPrevDay_Array () {
46
        $this->assertEqual(
47
            array(
48
                'year'   => 2002,
49
                'month'  => 12,
50
                'day'    => 31,
51
                'hour'   => 0,
52
                'minute' => 0,
53
                'second' => 0),
54
            $this->cal->prevDay('array'));
55
    }
56
    function testThisDay () {
57
        $this->assertEqual(1,$this->cal->thisDay());
58
    }
59
    function testNextDay () {
60
        $this->assertEqual(2,$this->cal->nextDay());
61
    }
62
    function testPrevHour () {
63
        $this->assertEqual(23,$this->cal->prevHour());
64
    }
65
    function testThisHour () {
66
        $this->assertEqual(0,$this->cal->thisHour());
67
    }
68
    function testNextHour () {
69
        $this->assertEqual(1,$this->cal->nextHour());
70
    }
71
    function testPrevMinute () {
72
        $this->assertEqual(59,$this->cal->prevMinute());
73
    }
74
    function testThisMinute () {
75
        $this->assertEqual(0,$this->cal->thisMinute());
76
    }
77
    function testNextMinute () {
78
        $this->assertEqual(1,$this->cal->nextMinute());
79
    }
80
    function testPrevSecond () {
81
        $this->assertEqual(59,$this->cal->prevSecond());
82
    }
83
    function testThisSecond () {
84
        $this->assertEqual(0,$this->cal->thisSecond());
85
    }
86
    function testNextSecond () {
87
        $this->assertEqual(1,$this->cal->nextSecond());
88
    }
89
    function testGetTimeStamp() {
90
        $stamp = mktime(0,0,0,1,1,2003);
91
        $this->assertEqual($stamp,$this->cal->getTimeStamp());
92
    }
93
}
94
 
95
class TestOfYearBuild extends TestOfYear {
96
    function TestOfYearBuild() {
97
        $this->UnitTestCase('Test of Year::build()');
98
    }
99
    function testSize() {
100
        $this->cal->build();
101
        $this->assertEqual(12,$this->cal->size());
102
    }
103
    function testFetch() {
104
        $this->cal->build();
105
        $i=0;
106
        while ( $Child = $this->cal->fetch() ) {
107
            $i++;
108
        }
109
        $this->assertEqual(12,$i);
110
    }
111
    function testFetchAll() {
112
        $this->cal->build();
113
        $children = array();
114
        $i = 1;
115
        while ( $Child = $this->cal->fetch() ) {
116
            $children[$i]=$Child;
117
            $i++;
118
        }
119
        $this->assertEqual($children,$this->cal->fetchAll());
120
    }
121
    function testSelection() {
122
        require_once(CALENDAR_ROOT . 'Month.php');
123
        $selection = array(new Calendar_Month(2003,10));
124
        $this->cal->build($selection);
125
        $i = 1;
126
        while ( $Child = $this->cal->fetch() ) {
127
            if ( $i == 10 )
128
                break;
129
            $i++;
130
        }
131
        $this->assertTrue($Child->isSelected());
132
    }
133
}
134
 
135
if (!defined('TEST_RUNNING')) {
136
    define('TEST_RUNNING', true);
137
    $test = &new TestOfYear();
138
    $test->run(new HtmlReporter());
139
    $test = &new TestOfYearBuild();
140
    $test->run(new HtmlReporter());
141
}
142
?>