9
9
10
10
use IntlDateFormatter ;
11
11
use DateTime ;
12
+ use DateTimeImmutable ;
12
13
use PHPUnit \Framework \TestCase ;
13
14
14
15
class RangerTest extends TestCase
@@ -22,7 +23,7 @@ public function testDateRange($language, $start, $end, $expected)
22
23
$ this ->assertEquals ($ expected , $ formatter ->format ($ start , $ end ));
23
24
}
24
25
25
- public function providerDateRange ()
26
+ public static function providerDateRange ()
26
27
{
27
28
return [
28
29
['en ' , '2013-10-05 ' , '2013-10-20 ' , 'Oct 5–20, 2013 ' ],
@@ -44,7 +45,7 @@ public function testDateTimeRange($language, $start, $end, $expected)
44
45
$ this ->assertEquals ($ expected , $ formatter ->format ($ start , $ end ));
45
46
}
46
47
47
- public function providerDateTimeRange ()
48
+ public static function providerDateTimeRange ()
48
49
{
49
50
return [
50
51
['en ' , '2013-10-05 01:01:01 ' , '2013-10-20 00:00:00 ' , 'Oct 5, 2013, 1:01 AM – Oct 20, 2013, 12:00 AM ' ],
@@ -64,7 +65,7 @@ public function testFullDateRange($language, $start, $end, $expected)
64
65
$ this ->assertEquals ($ expected , $ formatter ->format ($ start , $ end ));
65
66
}
66
67
67
- public function providerFullDateRange ()
68
+ public static function providerFullDateRange ()
68
69
{
69
70
return [
70
71
['en ' , '2013-10-05 ' , '2013-10-20 ' , 'Saturday, October 5 – Sunday, October 20, 2013 ' ],
@@ -86,7 +87,7 @@ public function testShortDateRange($language, $start, $end, $expected)
86
87
$ this ->assertEquals ($ expected , $ formatter ->format ($ start , $ end ));
87
88
}
88
89
89
- public function providerShortDateRange ()
90
+ public static function providerShortDateRange ()
90
91
{
91
92
return [
92
93
['en ' , '2012-10-05 ' , '2013-10-20 ' , '10/5/12 – 10/20/13 ' ],
@@ -135,6 +136,16 @@ public function testDateTime()
135
136
$ this ->assertEquals ('Oct 5–20, 2013 ' , $ formatted );
136
137
}
137
138
139
+ public function testDateTimeImmutable ()
140
+ {
141
+ $ ranger = new Ranger ('en ' );
142
+ $ start = new DateTimeImmutable ('2013-10-05 ' );
143
+ $ end = new DateTimeImmutable ('2013-10-20 ' );
144
+
145
+ $ formatted = $ ranger ->format ($ start , $ end );
146
+ $ this ->assertEquals ('Oct 5–20, 2013 ' , $ formatted );
147
+ }
148
+
138
149
public function testTimestamp ()
139
150
{
140
151
$ ranger = new Ranger ('en ' );
@@ -188,7 +199,7 @@ public function testNoDate($language, $start, $end, $expected)
188
199
$ this ->assertEquals ($ expected , $ formatter ->format ($ start , $ end ));
189
200
}
190
201
191
- public function providerNoDate ()
202
+ public static function providerNoDate ()
192
203
{
193
204
return [
194
205
['en ' , '2013-10-05 10:00:00 ' , '2013-10-05 13:30:00 ' , '10:00 AM – 1:30 PM ' ],
0 commit comments