@@ -143,23 +143,23 @@ public function testIntlAsTime()
143143 public function testAsTime ()
144144 {
145145 $ value = time ();
146- $ this ->assertSame (date ('g:i:s A ' , $ value ), $ this ->formatter ->asTime ($ value ));
146+ $ this ->assertSameAnyWhitespace (date ('g:i:s A ' , $ value ), $ this ->formatter ->asTime ($ value ));
147147 $ this ->assertSame (date ('h:i:s A ' , $ value ), $ this ->formatter ->asTime ($ value , 'php:h:i:s A ' ));
148148
149149 $ value = new DateTime ();
150- $ this ->assertSame (date ('g:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value ));
150+ $ this ->assertSameAnyWhitespace (date ('g:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value ));
151151 $ this ->assertSame (date ('h:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value , 'php:h:i:s A ' ));
152152
153153 if (version_compare (PHP_VERSION , '5.5.0 ' , '>= ' )) {
154154 $ value = new \DateTimeImmutable ();
155- $ this ->assertSame (date ('g:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value ));
155+ $ this ->assertSameAnyWhitespace (date ('g:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value ));
156156 $ this ->assertSame (date ('h:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asTime ($ value , 'php:h:i:s A ' ));
157157 }
158158
159159 // empty input
160- $ this ->assertSame ('12:00:00 AM ' , $ this ->formatter ->asTime ('' ));
161- $ this ->assertSame ('12:00:00 AM ' , $ this ->formatter ->asTime (0 ));
162- $ this ->assertSame ('12:00:00 AM ' , $ this ->formatter ->asTime (false ));
160+ $ this ->assertSameAnyWhitespace ('12:00:00 AM ' , $ this ->formatter ->asTime ('' ));
161+ $ this ->assertSameAnyWhitespace ('12:00:00 AM ' , $ this ->formatter ->asTime (0 ));
162+ $ this ->assertSameAnyWhitespace ('12:00:00 AM ' , $ this ->formatter ->asTime (false ));
163163 // null display
164164 $ this ->assertSame ($ this ->formatter ->nullDisplay , $ this ->formatter ->asTime (null ));
165165 }
@@ -178,23 +178,35 @@ public function testIntlAsDatetime()
178178 public function testAsDatetime ()
179179 {
180180 $ value = time ();
181- $ this ->assertRegExp (date ('~M j, Y,? g:i:s A~ ' , $ value ), $ this ->formatter ->asDatetime ($ value ));
181+ $ this ->assertRegExp (
182+ $ this ->sanitizeWhitespaces (date ('~M j, Y,? g:i:s A~ ' , $ value )),
183+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime ($ value ))
184+ );
182185 $ this ->assertSame (date ('Y/m/d h:i:s A ' , $ value ), $ this ->formatter ->asDatetime ($ value , 'php:Y/m/d h:i:s A ' ));
183186
184187 $ value = new DateTime ();
185- $ this ->assertRegExp (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ value ));
188+ $ this ->assertRegExp (
189+ $ this ->sanitizeWhitespaces (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ())),
190+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime ($ value ))
191+ );
186192 $ this ->assertSame (date ('Y/m/d h:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ value , 'php:Y/m/d h:i:s A ' ));
187193
188194 // empty time
189195 $ value = new DateTime ();
190196 $ date = $ value ->format ('Y-m-d ' );
191197 $ value = new DateTime ($ date );
192- $ this ->assertRegExp (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ date ));
198+ $ this ->assertRegExp (
199+ $ this ->sanitizeWhitespaces (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ())),
200+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime ($ date ))
201+ );
193202 $ this ->assertSame (date ('Y/m/d h:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ date , 'php:Y/m/d h:i:s A ' ));
194203
195204 if (PHP_VERSION_ID >= 50500 ) {
196205 $ value = new \DateTimeImmutable ();
197- $ this ->assertRegExp (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ value ));
206+ $ this ->assertRegExp (
207+ $ this ->sanitizeWhitespaces (date ('~M j, Y,? g:i:s A~ ' , $ value ->getTimestamp ())),
208+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime ($ value ))
209+ );
198210 $ this ->assertSame (date ('Y/m/d h:i:s A ' , $ value ->getTimestamp ()), $ this ->formatter ->asDatetime ($ value , 'php:Y/m/d h:i:s A ' ));
199211 }
200212
@@ -205,9 +217,18 @@ public function testAsDatetime()
205217 }
206218
207219 // empty input
208- $ this ->assertRegExp ('~Jan 1, 1970,? 12:00:00 AM~ ' , $ this ->formatter ->asDatetime ('' ));
209- $ this ->assertRegExp ('~Jan 1, 1970,? 12:00:00 AM~ ' , $ this ->formatter ->asDatetime (0 ));
210- $ this ->assertRegExp ('~Jan 1, 1970,? 12:00:00 AM~ ' , $ this ->formatter ->asDatetime (false ));
220+ $ this ->assertRegExp (
221+ $ this ->sanitizeWhitespaces ('~Jan 1, 1970,? 12:00:00 AM~ ' ),
222+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime ('' ))
223+ );
224+ $ this ->assertRegExp (
225+ $ this ->sanitizeWhitespaces ('~Jan 1, 1970,? 12:00:00 AM~ ' ),
226+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime (0 ))
227+ );
228+ $ this ->assertRegExp (
229+ $ this ->sanitizeWhitespaces ('~Jan 1, 1970,? 12:00:00 AM~ ' ),
230+ $ this ->sanitizeWhitespaces ($ this ->formatter ->asDatetime (false ))
231+ );
211232 // null display
212233 $ this ->assertSame ($ this ->formatter ->nullDisplay , $ this ->formatter ->asDatetime (null ));
213234 }
0 commit comments