@@ -139,4 +139,41 @@ public function testFormatObjectIfPassedWrongFormat()
139139 $ reflectionProperty ->setValue ($ dateTimeFormatter , $ this ->localeResolverMock );
140140 $ dateTimeFormatter ->formatObject (new \DateTime ('2013-06-06 17:05:06 Europe/Dublin ' ), new \StdClass ());
141141 }
142+
143+ /**
144+ * @dataProvider formatObjectNumericFormatDataProvider
145+ */
146+ public function testFormatObjectNumericFormat ($ format , $ expected )
147+ {
148+ /** @var DateTimeFormatter $dateTimeFormatter */
149+ $ dateTimeFormatter = $ this ->objectManager ->getObject (
150+ DateTimeFormatter::class,
151+ [
152+ 'useIntlFormatObject ' => false ,
153+ ]
154+ );
155+
156+ $ reflection = new \ReflectionClass (get_class ($ dateTimeFormatter ));
157+ $ reflectionProperty = $ reflection ->getProperty ('localeResolver ' );
158+ $ reflectionProperty ->setAccessible (true );
159+ $ reflectionProperty ->setValue ($ dateTimeFormatter , $ this ->localeResolverMock );
160+ $ result = $ dateTimeFormatter ->formatObject (
161+ new \DateTime ('2022-03-30 00:01:02 GMT ' ),
162+ $ format ,
163+ 'en_US '
164+ );
165+ $ this ->assertEquals ($ expected , $ result );
166+ }
167+
168+ public function formatObjectNumericFormatDataProvider ()
169+ {
170+ return [
171+ [null , 'Mar 30, 2022, 12:01:02 AM ' ],
172+ [\IntlDateFormatter::NONE , '12:01:02 AM Greenwich Mean Time ' ],
173+ [\IntlDateFormatter::SHORT , '3/30/22, 12:01:02 AM Greenwich Mean Time ' ],
174+ [\IntlDateFormatter::MEDIUM , 'Mar 30, 2022, 12:01:02 AM Greenwich Mean Time ' ],
175+ [\IntlDateFormatter::LONG , 'March 30, 2022 at 12:01:02 AM Greenwich Mean Time ' ],
176+ [\IntlDateFormatter::FULL , 'Wednesday, March 30, 2022 at 12:01:02 AM Greenwich Mean Time ' ],
177+ ];
178+ }
142179}
0 commit comments