This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace HMLB\Date\Tests\Date; |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Date package. |
||
7 | * |
||
8 | * (c) Hugues Maignol <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | use HMLB\Date\Date; |
||
15 | use HMLB\Date\Tests\AbstractTestCase; |
||
16 | |||
17 | class ComparisonTest extends AbstractTestCase |
||
18 | { |
||
19 | public function testEqualToTrue() |
||
20 | { |
||
21 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->equals(Date::createFromDate(2000, 1, 1))); |
||
22 | } |
||
23 | |||
24 | public function testEqualToFalse() |
||
25 | { |
||
26 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->equals(Date::createFromDate(2000, 1, 2))); |
||
27 | } |
||
28 | |||
29 | public function testEqualWithTimezoneTrue() |
||
30 | { |
||
31 | $this->assertTrue( |
||
32 | Date::create(2000, 1, 1, 12, 0, 0, 'America/Toronto')->equals( |
||
33 | Date::create(2000, 1, 1, 9, 0, 0, 'America/Vancouver') |
||
34 | ) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | public function testEqualWithTimezoneFalse() |
||
39 | { |
||
40 | $this->assertFalse( |
||
41 | Date::createFromDate(2000, 1, 1, 'America/Toronto')->equals( |
||
42 | Date::createFromDate(2000, 1, 1, 'America/Vancouver') |
||
43 | ) |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | public function testNotEqualToTrue() |
||
48 | { |
||
49 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->notEquals(Date::createFromDate(2000, 1, 2))); |
||
50 | } |
||
51 | |||
52 | public function testNotEqualToFalse() |
||
53 | { |
||
54 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->notEquals(Date::createFromDate(2000, 1, 1))); |
||
55 | } |
||
56 | |||
57 | public function testNotEqualWithTimezone() |
||
58 | { |
||
59 | $this->assertTrue( |
||
60 | Date::createFromDate(2000, 1, 1, 'America/Toronto')->notEquals( |
||
61 | Date::createFromDate(2000, 1, 1, 'America/Vancouver') |
||
62 | ) |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | public function testGreaterThanTrue() |
||
67 | { |
||
68 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isAfter(Date::createFromDate(1999, 12, 31))); |
||
69 | } |
||
70 | |||
71 | public function testGreaterThanFalse() |
||
72 | { |
||
73 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->isAfter(Date::createFromDate(2000, 1, 2))); |
||
74 | } |
||
75 | |||
76 | public function testGreaterThanWithTimezoneTrue() |
||
77 | { |
||
78 | $dt1 = Date::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); |
||
79 | $dt2 = Date::create(2000, 1, 1, 8, 59, 59, 'America/Vancouver'); |
||
80 | $this->assertTrue($dt1->isAfter($dt2)); |
||
81 | } |
||
82 | |||
83 | public function testGreaterThanWithTimezoneFalse() |
||
84 | { |
||
85 | $dt1 = Date::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); |
||
86 | $dt2 = Date::create(2000, 1, 1, 9, 0, 1, 'America/Vancouver'); |
||
87 | $this->assertFalse($dt1->isAfter($dt2)); |
||
88 | } |
||
89 | |||
90 | public function testGreaterThanOrEqualTrue() |
||
91 | { |
||
92 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isAfterOrEquals(Date::createFromDate(1999, 12, 31))); |
||
93 | } |
||
94 | |||
95 | public function testGreaterThanOrEqualTrueEqual() |
||
96 | { |
||
97 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isAfterOrEquals(Date::createFromDate(2000, 1, 1))); |
||
98 | } |
||
99 | |||
100 | public function testGreaterThanOrEqualFalse() |
||
101 | { |
||
102 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->isAfterOrEquals(Date::createFromDate(2000, 1, 2))); |
||
103 | } |
||
104 | |||
105 | public function testLessThanTrue() |
||
106 | { |
||
107 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isBefore(Date::createFromDate(2000, 1, 2))); |
||
108 | } |
||
109 | |||
110 | public function testLessThanFalse() |
||
111 | { |
||
112 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->isBefore(Date::createFromDate(1999, 12, 31))); |
||
113 | } |
||
114 | |||
115 | public function testLessThanOrEqualTrue() |
||
116 | { |
||
117 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isBeforeOrEquals(Date::createFromDate(2000, 1, 2))); |
||
118 | } |
||
119 | |||
120 | public function testLessThanOrEqualTrueEqual() |
||
121 | { |
||
122 | $this->assertTrue(Date::createFromDate(2000, 1, 1)->isBeforeOrEquals(Date::createFromDate(2000, 1, 1))); |
||
123 | } |
||
124 | |||
125 | public function testLessThanOrEqualFalse() |
||
126 | { |
||
127 | $this->assertFalse(Date::createFromDate(2000, 1, 1)->isBeforeOrEquals(Date::createFromDate(1999, 12, 31))); |
||
128 | } |
||
129 | |||
130 | View Code Duplication | public function testBetweenEqualTrue() |
|
0 ignored issues
–
show
|
|||
131 | { |
||
132 | $this->assertTrue( |
||
133 | Date::createFromDate(2000, 1, 15)->isBetween( |
||
134 | Date::createFromDate(2000, 1, 1), |
||
135 | Date::createFromDate(2000, 1, 31), |
||
136 | true |
||
137 | ) |
||
138 | ); |
||
139 | } |
||
140 | |||
141 | View Code Duplication | public function testBetweenNotEqualTrue() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
142 | { |
||
143 | $this->assertTrue( |
||
144 | Date::createFromDate(2000, 1, 15)->isBetween( |
||
145 | Date::createFromDate(2000, 1, 1), |
||
146 | Date::createFromDate(2000, 1, 31), |
||
147 | false |
||
148 | ) |
||
149 | ); |
||
150 | } |
||
151 | |||
152 | View Code Duplication | public function testBetweenEqualFalse() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
153 | { |
||
154 | $this->assertFalse( |
||
155 | Date::createFromDate(1999, 12, 31)->isBetween( |
||
156 | Date::createFromDate(2000, 1, 1), |
||
157 | Date::createFromDate(2000, 1, 31), |
||
158 | true |
||
159 | ) |
||
160 | ); |
||
161 | } |
||
162 | |||
163 | View Code Duplication | public function testBetweenNotEqualFalse() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
164 | { |
||
165 | $this->assertFalse( |
||
166 | Date::createFromDate(2000, 1, 1)->isBetween( |
||
167 | Date::createFromDate(2000, 1, 1), |
||
168 | Date::createFromDate(2000, 1, 31), |
||
169 | false |
||
170 | ) |
||
171 | ); |
||
172 | } |
||
173 | |||
174 | View Code Duplication | public function testBetweenEqualSwitchTrue() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
175 | { |
||
176 | $this->assertTrue( |
||
177 | Date::createFromDate(2000, 1, 15)->isBetween( |
||
178 | Date::createFromDate(2000, 1, 31), |
||
179 | Date::createFromDate(2000, 1, 1), |
||
180 | true |
||
181 | ) |
||
182 | ); |
||
183 | } |
||
184 | |||
185 | View Code Duplication | public function testBetweenNotEqualSwitchTrue() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
186 | { |
||
187 | $this->assertTrue( |
||
188 | Date::createFromDate(2000, 1, 15)->isBetween( |
||
189 | Date::createFromDate(2000, 1, 31), |
||
190 | Date::createFromDate(2000, 1, 1), |
||
191 | false |
||
192 | ) |
||
193 | ); |
||
194 | } |
||
195 | |||
196 | View Code Duplication | public function testBetweenEqualSwitchFalse() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
197 | { |
||
198 | $this->assertFalse( |
||
199 | Date::createFromDate(1999, 12, 31)->isBetween( |
||
200 | Date::createFromDate(2000, 1, 31), |
||
201 | Date::createFromDate(2000, 1, 1), |
||
202 | true |
||
203 | ) |
||
204 | ); |
||
205 | } |
||
206 | |||
207 | View Code Duplication | public function testBetweenNotEqualSwitchFalse() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
208 | { |
||
209 | $this->assertFalse( |
||
210 | Date::createFromDate(2000, 1, 1)->isBetween( |
||
211 | Date::createFromDate(2000, 1, 31), |
||
212 | Date::createFromDate(2000, 1, 1), |
||
213 | false |
||
214 | ) |
||
215 | ); |
||
216 | } |
||
217 | |||
218 | public function testMinIsFluid() |
||
219 | { |
||
220 | $dt = Date::now(); |
||
221 | $this->assertTrue($dt->min() instanceof Date); |
||
222 | } |
||
223 | |||
224 | public function testMinWithNow() |
||
225 | { |
||
226 | $dt = Date::create(2012, 1, 1, 0, 0, 0)->min(); |
||
227 | $this->assertDate($dt, 2012, 1, 1, 0, 0, 0); |
||
228 | } |
||
229 | |||
230 | public function testMinWithInstance() |
||
231 | { |
||
232 | $dt1 = Date::create(2013, 12, 31, 23, 59, 59); |
||
233 | $dt2 = Date::create(2012, 1, 1, 0, 0, 0)->min($dt1); |
||
234 | $this->assertDate($dt2, 2012, 1, 1, 0, 0, 0); |
||
235 | } |
||
236 | |||
237 | public function testMaxIsFluid() |
||
238 | { |
||
239 | $dt = Date::now(); |
||
240 | $this->assertTrue($dt->max() instanceof Date); |
||
241 | } |
||
242 | |||
243 | public function testMaxWithNow() |
||
244 | { |
||
245 | $dt = Date::create(2099, 12, 31, 23, 59, 59)->max(); |
||
246 | $this->assertDate($dt, 2099, 12, 31, 23, 59, 59); |
||
247 | } |
||
248 | |||
249 | public function testMaxWithInstance() |
||
250 | { |
||
251 | $dt1 = Date::create(2012, 1, 1, 0, 0, 0); |
||
252 | $dt2 = Date::create(2099, 12, 31, 23, 59, 59)->max($dt1); |
||
253 | $this->assertDate($dt2, 2099, 12, 31, 23, 59, 59); |
||
254 | } |
||
255 | |||
256 | public function testIsBirthday() |
||
257 | { |
||
258 | $dt = Date::now(); |
||
259 | $aBirthday = $dt->subYear(); |
||
260 | $this->assertTrue($aBirthday->isBirthday()); |
||
261 | $notABirthday = $dt->subDay(); |
||
262 | $this->assertFalse($notABirthday->isBirthday()); |
||
263 | $alsoNotABirthday = $dt->addDays(2); |
||
264 | $this->assertFalse($alsoNotABirthday->isBirthday()); |
||
265 | |||
266 | $dt1 = Date::createFromDate(1987, 4, 23); |
||
267 | $dt2 = Date::createFromDate(2014, 9, 26); |
||
268 | $dt3 = Date::createFromDate(2014, 4, 23); |
||
269 | $this->assertFalse($dt2->isBirthday($dt1)); |
||
270 | $this->assertTrue($dt3->isBirthday($dt1)); |
||
271 | } |
||
272 | |||
273 | View Code Duplication | public function testClosest() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
274 | { |
||
275 | $instance = Date::create(2015, 5, 28, 12, 0, 0); |
||
276 | $dt1 = Date::create(2015, 5, 28, 11, 0, 0); |
||
277 | $dt2 = Date::create(2015, 5, 28, 14, 0, 0); |
||
278 | $closest = $instance->closest($dt1, $dt2); |
||
279 | $this->assertEquals($dt1, $closest); |
||
280 | } |
||
281 | |||
282 | View Code Duplication | public function testClosestWithEquals() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
283 | { |
||
284 | $instance = Date::create(2015, 5, 28, 12, 0, 0); |
||
285 | $dt1 = Date::create(2015, 5, 28, 12, 0, 0); |
||
286 | $dt2 = Date::create(2015, 5, 28, 14, 0, 0); |
||
287 | $closest = $instance->closest($dt1, $dt2); |
||
288 | $this->assertEquals($dt1, $closest); |
||
289 | } |
||
290 | |||
291 | View Code Duplication | public function testFarthest() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
292 | { |
||
293 | $instance = Date::create(2015, 5, 28, 12, 0, 0); |
||
294 | $dt1 = Date::create(2015, 5, 28, 11, 0, 0); |
||
295 | $dt2 = Date::create(2015, 5, 28, 14, 0, 0); |
||
296 | $Farthest = $instance->farthest($dt1, $dt2); |
||
297 | $this->assertEquals($dt2, $Farthest); |
||
298 | } |
||
299 | |||
300 | View Code Duplication | public function testFarthestWithEquals() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
301 | { |
||
302 | $instance = Date::create(2015, 5, 28, 12, 0, 0); |
||
303 | $dt1 = Date::create(2015, 5, 28, 12, 0, 0); |
||
304 | $dt2 = Date::create(2015, 5, 28, 14, 0, 0); |
||
305 | $Farthest = $instance->farthest($dt1, $dt2); |
||
306 | $this->assertEquals($dt2, $Farthest); |
||
307 | } |
||
308 | } |
||
309 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.