|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require_once __DIR__ . '/simple_include.php'; |
|
4
|
|
|
require_once __DIR__ . '/calendar_include.php'; |
|
5
|
|
|
|
|
6
|
|
|
require_once __DIR__ . '/./decorator_test.php'; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class TestOfUtilTextual. |
|
10
|
|
|
*/ |
|
11
|
|
|
class TestOfUtilTextual extends UnitTestCase |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
public $mockengine; |
|
14
|
|
|
public $mockcal; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* TestOfUtilTextual constructor. |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct() |
|
20
|
|
|
{ |
|
21
|
|
|
parent::__construct('Test of Calendar_Util_Textual'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
protected function setUp() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->mockengine = new Mock_Calendar_Engine($this); |
|
|
|
|
|
|
27
|
|
|
$this->mockcal = new Mock_Calendar_Second($this); |
|
|
|
|
|
|
28
|
|
|
$this->mockcal->setReturnValue('prevYear', 2002); |
|
29
|
|
|
$this->mockcal->setReturnValue('thisYear', 2003); |
|
30
|
|
|
$this->mockcal->setReturnValue('nextYear', 2004); |
|
31
|
|
|
$this->mockcal->setReturnValue('prevMonth', 9); |
|
32
|
|
|
$this->mockcal->setReturnValue('thisMonth', 10); |
|
33
|
|
|
$this->mockcal->setReturnValue('nextMonth', 11); |
|
34
|
|
|
$this->mockcal->setReturnValue('prevDay', 14); |
|
35
|
|
|
$this->mockcal->setReturnValue('thisDay', 15); |
|
36
|
|
|
$this->mockcal->setReturnValue('nextDay', 16); |
|
37
|
|
|
$this->mockcal->setReturnValue('prevHour', 12); |
|
38
|
|
|
$this->mockcal->setReturnValue('thisHour', 13); |
|
39
|
|
|
$this->mockcal->setReturnValue('nextHour', 14); |
|
40
|
|
|
$this->mockcal->setReturnValue('prevMinute', 29); |
|
41
|
|
|
$this->mockcal->setReturnValue('thisMinute', 30); |
|
42
|
|
|
$this->mockcal->setReturnValue('nextMinute', 31); |
|
43
|
|
|
$this->mockcal->setReturnValue('prevSecond', 44); |
|
44
|
|
|
$this->mockcal->setReturnValue('thisSecond', 45); |
|
45
|
|
|
$this->mockcal->setReturnValue('nextSecond', 46); |
|
46
|
|
|
$this->mockcal->setReturnValue('getEngine', $this->mockengine); |
|
47
|
|
|
$this->mockcal->setReturnValue('getTimestamp', 12345); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
protected function tearDown() |
|
51
|
|
|
{ |
|
52
|
|
|
unset($this->engine, $this->mockcal); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testMonthNamesLong() |
|
56
|
|
|
{ |
|
57
|
|
|
$monthNames = [ |
|
58
|
|
|
1 => 'January', |
|
59
|
|
|
2 => 'February', |
|
60
|
|
|
3 => 'March', |
|
61
|
|
|
4 => 'April', |
|
62
|
|
|
5 => 'May', |
|
63
|
|
|
6 => 'June', |
|
64
|
|
|
7 => 'July', |
|
65
|
|
|
8 => 'August', |
|
66
|
|
|
9 => 'September', |
|
67
|
|
|
10 => 'October', |
|
68
|
|
|
11 => 'November', |
|
69
|
|
|
12 => 'December', |
|
70
|
|
|
]; |
|
71
|
|
|
$this->assertEqual($monthNames, Calendar_Util_Textual::monthNames()); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testMonthNamesShort() |
|
75
|
|
|
{ |
|
76
|
|
|
$monthNames = [ |
|
77
|
|
|
1 => 'Jan', |
|
78
|
|
|
2 => 'Feb', |
|
79
|
|
|
3 => 'Mar', |
|
80
|
|
|
4 => 'Apr', |
|
81
|
|
|
5 => 'May', |
|
82
|
|
|
6 => 'Jun', |
|
83
|
|
|
7 => 'Jul', |
|
84
|
|
|
8 => 'Aug', |
|
85
|
|
|
9 => 'Sep', |
|
86
|
|
|
10 => 'Oct', |
|
87
|
|
|
11 => 'Nov', |
|
88
|
|
|
12 => 'Dec', |
|
89
|
|
|
]; |
|
90
|
|
|
$this->assertEqual($monthNames, Calendar_Util_Textual::monthNames('short')); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function testMonthNamesTwo() |
|
94
|
|
|
{ |
|
95
|
|
|
$monthNames = [ |
|
96
|
|
|
1 => 'Ja', |
|
97
|
|
|
2 => 'Fe', |
|
98
|
|
|
3 => 'Ma', |
|
99
|
|
|
4 => 'Ap', |
|
100
|
|
|
5 => 'Ma', |
|
101
|
|
|
6 => 'Ju', |
|
102
|
|
|
7 => 'Ju', |
|
103
|
|
|
8 => 'Au', |
|
104
|
|
|
9 => 'Se', |
|
105
|
|
|
10 => 'Oc', |
|
106
|
|
|
11 => 'No', |
|
107
|
|
|
12 => 'De', |
|
108
|
|
|
]; |
|
109
|
|
|
$this->assertEqual($monthNames, Calendar_Util_Textual::monthNames('two')); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function testMonthNamesOne() |
|
113
|
|
|
{ |
|
114
|
|
|
$monthNames = [ |
|
115
|
|
|
1 => 'J', |
|
116
|
|
|
2 => 'F', |
|
117
|
|
|
3 => 'M', |
|
118
|
|
|
4 => 'A', |
|
119
|
|
|
5 => 'M', |
|
120
|
|
|
6 => 'J', |
|
121
|
|
|
7 => 'J', |
|
122
|
|
|
8 => 'A', |
|
123
|
|
|
9 => 'S', |
|
124
|
|
|
10 => 'O', |
|
125
|
|
|
11 => 'N', |
|
126
|
|
|
12 => 'D', |
|
127
|
|
|
]; |
|
128
|
|
|
$this->assertEqual($monthNames, Calendar_Util_Textual::monthNames('one')); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function testWeekdayNamesLong() |
|
132
|
|
|
{ |
|
133
|
|
|
$weekdayNames = [ |
|
134
|
|
|
0 => 'Sunday', |
|
135
|
|
|
1 => 'Monday', |
|
136
|
|
|
2 => 'Tuesday', |
|
137
|
|
|
3 => 'Wednesday', |
|
138
|
|
|
4 => 'Thursday', |
|
139
|
|
|
5 => 'Friday', |
|
140
|
|
|
6 => 'Saturday', |
|
141
|
|
|
]; |
|
142
|
|
|
$this->assertEqual($weekdayNames, Calendar_Util_Textual::weekdayNames()); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function testWeekdayNamesShort() |
|
146
|
|
|
{ |
|
147
|
|
|
$weekdayNames = [ |
|
148
|
|
|
0 => 'Sun', |
|
149
|
|
|
1 => 'Mon', |
|
150
|
|
|
2 => 'Tue', |
|
151
|
|
|
3 => 'Wed', |
|
152
|
|
|
4 => 'Thu', |
|
153
|
|
|
5 => 'Fri', |
|
154
|
|
|
6 => 'Sat', |
|
155
|
|
|
]; |
|
156
|
|
|
$this->assertEqual($weekdayNames, Calendar_Util_Textual::weekdayNames('short')); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function testWeekdayNamesTwo() |
|
160
|
|
|
{ |
|
161
|
|
|
$weekdayNames = [ |
|
162
|
|
|
0 => 'Su', |
|
163
|
|
|
1 => 'Mo', |
|
164
|
|
|
2 => 'Tu', |
|
165
|
|
|
3 => 'We', |
|
166
|
|
|
4 => 'Th', |
|
167
|
|
|
5 => 'Fr', |
|
168
|
|
|
6 => 'Sa', |
|
169
|
|
|
]; |
|
170
|
|
|
$this->assertEqual($weekdayNames, Calendar_Util_Textual::weekdayNames('two')); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
public function testWeekdayNamesOne() |
|
174
|
|
|
{ |
|
175
|
|
|
$weekdayNames = [ |
|
176
|
|
|
0 => 'S', |
|
177
|
|
|
1 => 'M', |
|
178
|
|
|
2 => 'T', |
|
179
|
|
|
3 => 'W', |
|
180
|
|
|
4 => 'T', |
|
181
|
|
|
5 => 'F', |
|
182
|
|
|
6 => 'S', |
|
183
|
|
|
]; |
|
184
|
|
|
$this->assertEqual($weekdayNames, Calendar_Util_Textual::weekdayNames('one')); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function testPrevMonthNameShort() |
|
188
|
|
|
{ |
|
189
|
|
|
$this->assertEqual('Sep', Calendar_Util_Textual::prevMonthName($this->mockcal, 'short')); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function testThisMonthNameShort() |
|
193
|
|
|
{ |
|
194
|
|
|
$this->assertEqual('Oct', Calendar_Util_Textual::thisMonthName($this->mockcal, 'short')); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
public function testNextMonthNameShort() |
|
198
|
|
|
{ |
|
199
|
|
|
$this->assertEqual('Nov', Calendar_Util_Textual::nextMonthName($this->mockcal, 'short')); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function testThisDayNameShort() |
|
203
|
|
|
{ |
|
204
|
|
|
$this->assertEqual('Wed', Calendar_Util_Textual::thisDayName($this->mockcal, 'short')); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function testOrderedWeekdaysShort() |
|
208
|
|
|
{ |
|
209
|
|
|
$weekdayNames = [ |
|
210
|
|
|
0 => 'Sun', |
|
211
|
|
|
1 => 'Mon', |
|
212
|
|
|
2 => 'Tue', |
|
213
|
|
|
3 => 'Wed', |
|
214
|
|
|
4 => 'Thu', |
|
215
|
|
|
5 => 'Fri', |
|
216
|
|
|
6 => 'Sat', |
|
217
|
|
|
]; |
|
218
|
|
|
$nShifts = CALENDAR_FIRST_DAY_OF_WEEK; |
|
219
|
|
|
while ($nShifts-- > 0) { |
|
220
|
|
|
$day = array_shift($weekdayNames); |
|
221
|
|
|
array_push($weekdayNames, $day); |
|
222
|
|
|
} |
|
223
|
|
|
$this->assertEqual($weekdayNames, Calendar_Util_Textual::orderedWeekdays($this->mockcal, 'short')); |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
if (!defined('TEST_RUNNING')) { |
|
228
|
|
|
define('TEST_RUNNING', true); |
|
229
|
|
|
$test = new TestOfUtilTextual(); |
|
230
|
|
|
$test->run(new HtmlReporter()); |
|
|
|
|
|
|
231
|
|
|
} |
|
232
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths