Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

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