@@ -18,31 +18,32 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
1818{
1919 public function testConstructor ()
2020 {
21- $ formatter = new IntlDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , 'y-M-d ' );
21+ $ formatter = $ this -> getDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , 'y-M-d ' );
2222 $ this ->assertEquals ('y-M-d ' , $ formatter ->getPattern ());
2323 }
2424
2525 public function testConstructorWithoutLocale ()
2626 {
27- $ formatter = new IntlDateFormatter (null , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , 'y-M-d ' );
27+ $ formatter = $ this -> getDateFormatter (null , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , 'y-M-d ' );
2828 $ this ->assertEquals ('y-M-d ' , $ formatter ->getPattern ());
2929 }
3030
3131 public function testConstructorWithoutCalendar ()
3232 {
33- $ formatter = new IntlDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , null , 'y-M-d ' );
33+ $ formatter = $ this -> getDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , null , 'y-M-d ' );
3434 $ this ->assertEquals ('y-M-d ' , $ formatter ->getPattern ());
3535 }
3636
3737 public function testConstructorWithUnsupportedLocale ()
3838 {
3939 $ this ->expectException ('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException ' );
40- new IntlDateFormatter ('pt_BR ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT );
40+ $ this -> getDateFormatter ('pt_BR ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT );
4141 }
4242
4343 public function testStaticCreate ()
4444 {
45- $ formatter = IntlDateFormatter::create ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT );
45+ $ formatter = $ this ->getDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT );
46+ $ formatter = $ formatter ::create ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT );
4647 $ this ->assertInstanceOf ('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter ' , $ formatter );
4748 }
4849
@@ -75,7 +76,7 @@ public function testFormatWithUnimplementedChars()
7576 {
7677 $ this ->expectException ('Symfony\Component\Intl\Exception\NotImplementedException ' );
7778 $ pattern = 'Y ' ;
78- $ formatter = new IntlDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , $ pattern );
79+ $ formatter = $ this -> getDateFormatter ('en ' , IntlDateFormatter::MEDIUM , IntlDateFormatter::SHORT , 'UTC ' , IntlDateFormatter::GREGORIAN , $ pattern );
7980 $ formatter ->format (0 );
8081 }
8182
@@ -178,7 +179,8 @@ public function testParseThreeDigitsYears()
178179
179180 protected function getDateFormatter ($ locale , $ datetype , $ timetype , $ timezone = null , $ calendar = IntlDateFormatter::GREGORIAN , $ pattern = null )
180181 {
181- return new IntlDateFormatter ($ locale , $ datetype , $ timetype , $ timezone , $ calendar , $ pattern );
182+ return new class ($ locale , $ datetype , $ timetype , $ timezone , $ calendar , $ pattern ) extends IntlDateFormatter {
183+ };
182184 }
183185
184186 protected function getIntlErrorMessage ()
0 commit comments