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 TestOfMonth. |
10
|
|
|
*/ |
11
|
|
|
class TestOfMonth extends TestOfCalendar |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* TestOfMonth constructor. |
15
|
|
|
*/ |
16
|
|
|
public function __construct() |
17
|
|
|
{ |
18
|
|
|
$this->UnitTestCase('Test of Month'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function setUp() |
22
|
|
|
{ |
23
|
|
|
$this->cal = new Calendar_Month(2003, 10); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testPrevMonth_Object() |
27
|
|
|
{ |
28
|
|
|
$this->assertEqual(new Calendar_Month(2003, 9), $this->cal->prevMonth('object')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testPrevDay() |
32
|
|
|
{ |
33
|
|
|
$this->assertEqual(30, $this->cal->prevDay()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testPrevDay_Array() |
37
|
|
|
{ |
38
|
|
|
$this->assertEqual([ |
39
|
|
|
'year' => 2003, |
40
|
|
|
'month' => 9, |
41
|
|
|
'day' => 30, |
42
|
|
|
'hour' => 0, |
43
|
|
|
'minute' => 0, |
44
|
|
|
'second' => 0, |
45
|
|
|
], $this->cal->prevDay('array')); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testThisDay() |
49
|
|
|
{ |
50
|
|
|
$this->assertEqual(1, $this->cal->thisDay()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testNextDay() |
54
|
|
|
{ |
55
|
|
|
$this->assertEqual(2, $this->cal->nextDay()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testPrevHour() |
59
|
|
|
{ |
60
|
|
|
$this->assertEqual(23, $this->cal->prevHour()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testThisHour() |
64
|
|
|
{ |
65
|
|
|
$this->assertEqual(0, $this->cal->thisHour()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testNextHour() |
69
|
|
|
{ |
70
|
|
|
$this->assertEqual(1, $this->cal->nextHour()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testPrevMinute() |
74
|
|
|
{ |
75
|
|
|
$this->assertEqual(59, $this->cal->prevMinute()); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testThisMinute() |
79
|
|
|
{ |
80
|
|
|
$this->assertEqual(0, $this->cal->thisMinute()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function testNextMinute() |
84
|
|
|
{ |
85
|
|
|
$this->assertEqual(1, $this->cal->nextMinute()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testPrevSecond() |
89
|
|
|
{ |
90
|
|
|
$this->assertEqual(59, $this->cal->prevSecond()); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function testThisSecond() |
94
|
|
|
{ |
95
|
|
|
$this->assertEqual(0, $this->cal->thisSecond()); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function testNextSecond() |
99
|
|
|
{ |
100
|
|
|
$this->assertEqual(1, $this->cal->nextSecond()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function testGetTimeStamp() |
104
|
|
|
{ |
105
|
|
|
$stamp = mktime(0, 0, 0, 10, 1, 2003); |
106
|
|
|
$this->assertEqual($stamp, $this->cal->getTimestamp()); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Class TestOfMonthBuild. |
112
|
|
|
*/ |
113
|
|
|
class TestOfMonthBuild extends TestOfMonth |
114
|
|
|
{ |
115
|
|
|
/** |
116
|
|
|
* TestOfMonthBuild constructor. |
117
|
|
|
*/ |
118
|
|
|
public function __construct() |
119
|
|
|
{ |
120
|
|
|
$this->UnitTestCase('Test of Month::build()'); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function testSize() |
124
|
|
|
{ |
125
|
|
|
$this->cal->build(); |
126
|
|
|
$this->assertEqual(31, $this->cal->size()); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function testFetch() |
130
|
|
|
{ |
131
|
|
|
$this->cal->build(); |
132
|
|
|
$i = 0; |
133
|
|
|
while ($Child = $this->cal->fetch()) { |
|
|
|
|
134
|
|
|
++$i; |
135
|
|
|
} |
136
|
|
|
$this->assertEqual(31, $i); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function testFetchAll() |
140
|
|
|
{ |
141
|
|
|
$this->cal->build(); |
142
|
|
|
$children = []; |
143
|
|
|
$i = 1; |
144
|
|
|
while ($Child = $this->cal->fetch()) { |
145
|
|
|
$children[$i] = $Child; |
146
|
|
|
++$i; |
147
|
|
|
} |
148
|
|
|
$this->assertEqual($children, $this->cal->fetchAll()); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function testSelection() |
152
|
|
|
{ |
153
|
|
|
require_once CALENDAR_ROOT . 'Day.php'; |
154
|
|
|
$selection = [new Calendar_Day(2003, 10, 25)]; |
155
|
|
|
$this->cal->build($selection); |
156
|
|
|
$i = 1; |
157
|
|
|
while ($Child = $this->cal->fetch()) { |
158
|
|
|
if (25 == $i) { |
159
|
|
|
break; |
160
|
|
|
} |
161
|
|
|
++$i; |
162
|
|
|
} |
163
|
|
|
$this->assertTrue($Child->isSelected()); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
if (!defined('TEST_RUNNING')) { |
168
|
|
|
define('TEST_RUNNING', true); |
169
|
|
|
$test = new TestOfMonth(); |
170
|
|
|
$test->run(new HtmlReporter()); |
|
|
|
|
171
|
|
|
$test = new TestOfMonthBuild(); |
172
|
|
|
$test->run(new HtmlReporter()); |
173
|
|
|
} |
174
|
|
|
|