1 | <?php |
---|
2 | // $Id: hour_test.php,v 1.1 2004/05/24 22:25:43 quipo Exp $ |
---|
3 | |
---|
4 | require_once('simple_include.php'); |
---|
5 | require_once('calendar_include.php'); |
---|
6 | |
---|
7 | require_once('./calendar_test.php'); |
---|
8 | |
---|
9 | class TestOfHour extends TestOfCalendar { |
---|
10 | function TestOfHour() { |
---|
11 | $this->UnitTestCase('Test of Hour'); |
---|
12 | } |
---|
13 | function setUp() { |
---|
14 | $this->cal = new Calendar_Hour(2003,10,25,13); |
---|
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 testPrevMinute () { |
---|
28 | $this->assertEqual(59,$this->cal->prevMinute()); |
---|
29 | } |
---|
30 | function testThisMinute () { |
---|
31 | $this->assertEqual(0,$this->cal->thisMinute()); |
---|
32 | } |
---|
33 | function testNextMinute () { |
---|
34 | $this->assertEqual(1,$this->cal->nextMinute()); |
---|
35 | } |
---|
36 | function testPrevSecond () { |
---|
37 | $this->assertEqual(59,$this->cal->prevSecond()); |
---|
38 | } |
---|
39 | function testThisSecond () { |
---|
40 | $this->assertEqual(0,$this->cal->thisSecond()); |
---|
41 | } |
---|
42 | function testNextSecond () { |
---|
43 | $this->assertEqual(1,$this->cal->nextSecond()); |
---|
44 | } |
---|
45 | function testGetTimeStamp() { |
---|
46 | $stamp = mktime(13,0,0,10,25,2003); |
---|
47 | $this->assertEqual($stamp,$this->cal->getTimeStamp()); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | class TestOfHourBuild extends TestOfHour { |
---|
52 | function TestOfHourBuild() { |
---|
53 | $this->UnitTestCase('Test of Hour::build()'); |
---|
54 | } |
---|
55 | function testSize() { |
---|
56 | $this->cal->build(); |
---|
57 | $this->assertEqual(60,$this->cal->size()); |
---|
58 | } |
---|
59 | function testFetch() { |
---|
60 | $this->cal->build(); |
---|
61 | $i=0; |
---|
62 | while ( $Child = $this->cal->fetch() ) { |
---|
63 | $i++; |
---|
64 | } |
---|
65 | $this->assertEqual(60,$i); |
---|
66 | } |
---|
67 | function testFetchAll() { |
---|
68 | $this->cal->build(); |
---|
69 | $children = array(); |
---|
70 | $i = 0; |
---|
71 | while ( $Child = $this->cal->fetch() ) { |
---|
72 | $children[$i]=$Child; |
---|
73 | $i++; |
---|
74 | } |
---|
75 | $this->assertEqual($children,$this->cal->fetchAll()); |
---|
76 | } |
---|
77 | function testSelection() { |
---|
78 | require_once(CALENDAR_ROOT . 'Minute.php'); |
---|
79 | $selection = array(new Calendar_Minute(2003,10,25,13,32)); |
---|
80 | $this->cal->build($selection); |
---|
81 | $i = 0; |
---|
82 | while ( $Child = $this->cal->fetch() ) { |
---|
83 | if ( $i == 32 ) |
---|
84 | break; |
---|
85 | $i++; |
---|
86 | } |
---|
87 | $this->assertTrue($Child->isSelected()); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | if (!defined('TEST_RUNNING')) { |
---|
92 | define('TEST_RUNNING', true); |
---|
93 | $test = &new TestOfHour(); |
---|
94 | $test->run(new HtmlReporter()); |
---|
95 | $test = &new TestOfHourBuild(); |
---|
96 | $test->run(new HtmlReporter()); |
---|
97 | } |
---|
98 | ?> |
---|