|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require_once __DIR__ . '/simple_include.php'; |
|
4
|
|
|
require_once __DIR__ . '/calendar_include.php'; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class TestOfPearDateEngine. |
|
8
|
|
|
*/ |
|
9
|
|
|
class TestOfPearDateEngine extends UnitTestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
public $engine; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* TestOfPearDateEngine constructor. |
|
15
|
|
|
*/ |
|
16
|
|
|
public function __construct() |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct('Test of Calendar_Engine_PearDate'); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
protected function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->engine = new Calendar_Engine_PearDate(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testGetSecondsInMinute() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->assertEqual($this->engine->getSecondsInMinute(), _EXTCAL_TS_MINUTE); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testGetMinutesInHour() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->assertEqual($this->engine->getMinutesInHour(), _EXTCAL_TS_MINUTE); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testGetHoursInDay() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->assertEqual($this->engine->getHoursInDay(), 24); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testGetFirstDayOfWeek() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->assertEqual($this->engine->getFirstDayOfWeek(), 1); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetWeekDays() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->assertEqual($this->engine->getWeekDays(), [0, 1, 2, 3, 4, 5, 6]); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testGetDaysInWeek() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->assertEqual($this->engine->getDaysInWeek(), 7); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testGetWeekNInYear() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->assertEqual($this->engine->getWeekNInYear(2003, 11, 3), 45); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testGetWeekNInMonth() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->assertEqual($this->engine->getWeekNInMonth(2003, 11, 3), 2); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function testGetWeeksInMonth0() |
|
67
|
|
|
{ |
|
68
|
|
|
$this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 0), 6); //week starts on sunday |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function testGetWeeksInMonth1() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 1), 5); //week starts on monday |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function testGetWeeksInMonth2() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->assertEqual($this->engine->getWeeksInMonth(2003, 2, 6), 4); //week starts on saturday |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function testGetWeeksInMonth3() |
|
82
|
|
|
{ |
|
83
|
|
|
// Unusual cases that can cause fails (shows up with example 21.php) |
|
84
|
|
|
$this->assertEqual($this->engine->getWeeksInMonth(2004, 2, 1), 5); |
|
85
|
|
|
$this->assertEqual($this->engine->getWeeksInMonth(2004, 8, 1), 6); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function testGetDayOfWeek() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->assertEqual($this->engine->getDayOfWeek(2003, 11, 18), 2); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function testGetFirstDayInMonth() |
|
94
|
|
|
{ |
|
95
|
|
|
$this->assertEqual($this->engine->getFirstDayInMonth(2003, 10), 3); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function testGetDaysInMonth() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->assertEqual($this->engine->getDaysInMonth(2003, 10), 31); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function testGetMinYears() |
|
104
|
|
|
{ |
|
105
|
|
|
$this->assertEqual($this->engine->getMinYears(), 0); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function testGetMaxYears() |
|
109
|
|
|
{ |
|
110
|
|
|
$this->assertEqual($this->engine->getMaxYears(), 9999); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function testDateToStamp() |
|
114
|
|
|
{ |
|
115
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
116
|
|
|
$this->assertEqual($this->engine->dateToStamp(2003, 10, 15, 13, 30, 45), $stamp); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function testStampToSecond() |
|
120
|
|
|
{ |
|
121
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
122
|
|
|
$this->assertEqual($this->engine->stampToSecond($stamp), 45); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function testStampToMinute() |
|
126
|
|
|
{ |
|
127
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
128
|
|
|
$this->assertEqual($this->engine->stampToMinute($stamp), 30); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function testStampToHour() |
|
132
|
|
|
{ |
|
133
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
134
|
|
|
$this->assertEqual($this->engine->stampToHour($stamp), 13); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function testStampToDay() |
|
138
|
|
|
{ |
|
139
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
140
|
|
|
$this->assertEqual($this->engine->stampToDay($stamp), 15); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function testStampToMonth() |
|
144
|
|
|
{ |
|
145
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
146
|
|
|
$this->assertEqual($this->engine->stampToMonth($stamp), 10); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function testStampToYear() |
|
150
|
|
|
{ |
|
151
|
|
|
$stamp = '2003-10-15 13:30:45'; |
|
152
|
|
|
$this->assertEqual($this->engine->stampToYear($stamp), 2003); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function testAdjustDate() |
|
156
|
|
|
{ |
|
157
|
|
|
$stamp = '2004-01-01 13:30:45'; |
|
158
|
|
|
$y = $this->engine->stampToYear($stamp); |
|
159
|
|
|
$m = $this->engine->stampToMonth($stamp); |
|
160
|
|
|
$d = $this->engine->stampToDay($stamp); |
|
161
|
|
|
|
|
162
|
|
|
//the first day of the month should be thursday |
|
163
|
|
|
$this->assertEqual($this->engine->getDayOfWeek($y, $m, $d), 4); |
|
164
|
|
|
|
|
165
|
|
|
--$m; // 2004-00-01 => 2003-12-01 |
|
166
|
|
|
$this->engine->adjustDate($y, $m, $d, $dummy, $dummy, $dummy); |
|
|
|
|
|
|
167
|
|
|
|
|
168
|
|
|
$this->assertEqual($y, 2003); |
|
169
|
|
|
$this->assertEqual($m, 12); |
|
170
|
|
|
$this->assertEqual($d, 1); |
|
171
|
|
|
|
|
172
|
|
|
// get last day and check if it's wednesday |
|
173
|
|
|
$d = $this->engine->getDaysInMonth($y, $m); |
|
174
|
|
|
|
|
175
|
|
|
$this->assertEqual($this->engine->getDayOfWeek($y, $m, $d), 3); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function testIsToday() |
|
179
|
|
|
{ |
|
180
|
|
|
$stamp = date('Y-m-d H:i:s'); |
|
181
|
|
|
$this->assertTrue($this->engine->isToday($stamp)); |
|
182
|
|
|
$stamp = date('Y-m-d H:i:s', time() + 1000000000); |
|
183
|
|
|
$this->assertFalse($this->engine->isToday($stamp)); |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
if (!defined('TEST_RUNNING')) { |
|
188
|
|
|
define('TEST_RUNNING', true); |
|
189
|
|
|
$test = new TestOfPearDateEngine(); |
|
190
|
|
|
$test->run(new HtmlReporter()); |
|
|
|
|
|
|
191
|
|
|
} |
|
192
|
|
|
|
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