|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require_once __DIR__ . '/simple_include.php'; |
|
4
|
|
|
require_once __DIR__ . '/calendar_include.php'; |
|
5
|
|
|
|
|
6
|
|
|
require_once __DIR__ . '/./calendar_test.php'; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class TestOfHour. |
|
10
|
|
|
*/ |
|
11
|
|
|
class TestOfHour extends TestOfCalendar |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* TestOfHour constructor. |
|
15
|
|
|
*/ |
|
16
|
|
|
public function __construct() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->UnitTestCase('Test of Hour'); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->cal = new Calendar_Hour(2003, 10, 25, 13); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testPrevDay_Array() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->assertEqual([ |
|
29
|
|
|
'year' => 2003, |
|
30
|
|
|
'month' => 10, |
|
31
|
|
|
'day' => 24, |
|
32
|
|
|
'hour' => 0, |
|
33
|
|
|
'minute' => 0, |
|
34
|
|
|
'second' => 0, |
|
35
|
|
|
], $this->cal->prevDay('array')); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testPrevMinute() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->assertEqual(59, $this->cal->prevMinute()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testThisMinute() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->assertEqual(0, $this->cal->thisMinute()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testNextMinute() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->assertEqual(1, $this->cal->nextMinute()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testPrevSecond() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->assertEqual(59, $this->cal->prevSecond()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testThisSecond() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->assertEqual(0, $this->cal->thisSecond()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testNextSecond() |
|
64
|
|
|
{ |
|
65
|
|
|
$this->assertEqual(1, $this->cal->nextSecond()); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testGetTimeStamp() |
|
69
|
|
|
{ |
|
70
|
|
|
$stamp = mktime(13, 0, 0, 10, 25, 2003); |
|
71
|
|
|
$this->assertEqual($stamp, $this->cal->getTimestamp()); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Class TestOfHourBuild. |
|
77
|
|
|
*/ |
|
78
|
|
|
class TestOfHourBuild extends TestOfHour |
|
79
|
|
|
{ |
|
80
|
|
|
/** |
|
81
|
|
|
* TestOfHourBuild constructor. |
|
82
|
|
|
*/ |
|
83
|
|
|
public function __construct() |
|
84
|
|
|
{ |
|
85
|
|
|
$this->UnitTestCase('Test of Hour::build()'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function testSize() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->cal->build(); |
|
91
|
|
|
$this->assertEqual(_EXTCAL_TS_MINUTE, $this->cal->size()); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function testFetch() |
|
95
|
|
|
{ |
|
96
|
|
|
$this->cal->build(); |
|
97
|
|
|
$i = 0; |
|
98
|
|
|
while ($Child = $this->cal->fetch()) { |
|
|
|
|
|
|
99
|
|
|
++$i; |
|
100
|
|
|
} |
|
101
|
|
|
$this->assertEqual(_EXTCAL_TS_MINUTE, $i); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function testFetchAll() |
|
105
|
|
|
{ |
|
106
|
|
|
$this->cal->build(); |
|
107
|
|
|
$children = []; |
|
108
|
|
|
$i = 0; |
|
109
|
|
|
while ($Child = $this->cal->fetch()) { |
|
110
|
|
|
$children[$i] = $Child; |
|
111
|
|
|
++$i; |
|
112
|
|
|
} |
|
113
|
|
|
$this->assertEqual($children, $this->cal->fetchAll()); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function testSelection() |
|
117
|
|
|
{ |
|
118
|
|
|
require_once CALENDAR_ROOT . 'Minute.php'; |
|
119
|
|
|
$selection = [new Calendar_Minute(2003, 10, 25, 13, 32)]; |
|
120
|
|
|
$this->cal->build($selection); |
|
121
|
|
|
$i = 0; |
|
122
|
|
|
while ($Child = $this->cal->fetch()) { |
|
123
|
|
|
if (32 == $i) { |
|
124
|
|
|
break; |
|
125
|
|
|
} |
|
126
|
|
|
++$i; |
|
127
|
|
|
} |
|
128
|
|
|
$this->assertTrue($Child->isSelected()); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
if (!defined('TEST_RUNNING')) { |
|
133
|
|
|
define('TEST_RUNNING', true); |
|
134
|
|
|
$test = new TestOfHour(); |
|
135
|
|
|
$test->run(new HtmlReporter()); |
|
|
|
|
|
|
136
|
|
|
$test = new TestOfHourBuild(); |
|
137
|
|
|
$test->run(new HtmlReporter()); |
|
138
|
|
|
} |
|
139
|
|
|
|