Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

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