@@ -517,8 +517,11 @@ public function testLocaltime()
517
517
/**
518
518
* @dataProvider parseProvider
519
519
*/
520
- public function testParseIntl ($ pattern , $ value , $ expected, $ errorCode = 0 , $ errorMessage = ' U_ZERO_ERROR ' )
520
+ public function testParseIntl ($ pattern , $ value , $ expected )
521
521
{
522
+ $ errorCode = StubIntl::U_ZERO_ERROR ;
523
+ $ errorMessage = 'U_ZERO_ERROR ' ;
524
+
522
525
$ this ->skipIfIntlExtensionIsNotLoaded ();
523
526
$ formatter = $ this ->createIntlFormatter ($ pattern );
524
527
$ this ->assertSame ($ expected , $ formatter ->parse ($ value ));
@@ -530,8 +533,11 @@ public function testParseIntl($pattern, $value, $expected, $errorCode = 0, $erro
530
533
/**
531
534
* @dataProvider parseProvider
532
535
*/
533
- public function testParseStub ($ pattern , $ value , $ expected, $ errorCode = 0 , $ errorMessage = ' U_ZERO_ERROR ' )
536
+ public function testParseStub ($ pattern , $ value , $ expected )
534
537
{
538
+ $ errorCode = StubIntl::U_ZERO_ERROR ;
539
+ $ errorMessage = 'U_ZERO_ERROR ' ;
540
+
535
541
$ formatter = $ this ->createStubFormatter ($ pattern );
536
542
$ this ->assertSame ($ expected , $ formatter ->parse ($ value ));
537
543
$ this ->assertSame ($ errorMessage , StubIntl::getErrorMessage ());
@@ -551,19 +557,11 @@ public function parseProvider()
551
557
array ('y-MMM-d ' , '1970-Jan-1 ' , 0 ),
552
558
array ('y-MMMM-d ' , '1970-January-1 ' , 0 ),
553
559
554
- // 1 char month
555
- array ('y-MMMMM-d ' , '1970-J-1 ' , false , 9 , 'Date parsing failed: U_PARSE_ERROR ' ),
556
- array ('y-MMMMM-d ' , '1970-S-1 ' , false , 9 , 'Date parsing failed: U_PARSE_ERROR ' ),
557
-
558
560
// standalone months
559
561
array ('y-L-d ' , '1970-1-1 ' , 0 ),
560
562
array ('y-LLL-d ' , '1970-Jan-1 ' , 0 ),
561
563
array ('y-LLLL-d ' , '1970-January-1 ' , 0 ),
562
564
563
- // standalone 1 char month
564
- array ('y-LLLLL-d ' , '1970-J-1 ' , false , 9 , 'Date parsing failed: U_PARSE_ERROR ' ),
565
- array ('y-LLLLL-d ' , '1970-S-1 ' , false , 9 , 'Date parsing failed: U_PARSE_ERROR ' ),
566
-
567
565
// days
568
566
array ('y-M-d ' , '1970-1-1 ' , 0 ),
569
567
array ('y-M-dd ' , '1970-1-01 ' , 0 ),
@@ -690,6 +688,53 @@ public function p
10000
arseProvider()
690
688
);
691
689
}
692
690
691
+ /**
692
+ * @dataProvider parseErrorProvider
693
+ */
694
+ public function testParseErrorIntl ($ pattern , $ value )
695
+ {
696
+ $ errorCode = StubIntl::U_PARSE_ERROR ;
697
+ $ errorMessage = 'Date parsing failed: U_PARSE_ERROR ' ;
698
+
699
+ $ this ->skipIfIntlExtensionIsNotLoaded ();
700
+ $ formatter = $ this ->createIntlFormatter ($ pattern );
701
+ $ this ->assertSame (false , $ formatter ->parse ($ value ));
702
+ $ this ->assertSame ($ errorMessage , intl_get_error_message ());
703
+ $ this ->assertSame ($ errorCode , intl_get_error_code ());
704
+ $ this ->assertSame ($ errorCode != 0 , intl_is_failure (intl_get_error_code ()));
705
+ }
706
+
707
+ /**
708
+ * @dataProvider parseErrorProvider
709
+ */
710
+ public function testParseErrorStub ($ pattern , $ value )
711
+ {
712
+ $ errorCode = StubIntl::U_PARSE_ERROR ;
713
+ $ errorMessage = 'Date parsing failed: U_PARSE_ERROR ' ;
714
+
715
+ $ formatter = $ this ->createStubFormatter ($ pattern );
716
+ $ this ->assertSame (false , $ formatter ->parse ($ value ));
717
+ $ this ->assertSame ($ errorMessage , StubIntl::getErrorMessage ());
718
+ $ this ->assertSame ($ errorCode , StubIntl::getErrorCode ());
719
+ $ this ->assertSame ($ errorCode != 0 , StubIntl::isFailure (StubIntl::getErrorCode ()));
720
+ }
721
+
722
+ public function parseErrorProvider ()
723
+ {
724
+ return array (
725
+ array ('y-M-d ' , '1970/1/1 ' ),
726
+ array ('yy-M-d ' , '70/1/1 ' ),
727
+
728
+ // 1 char month
729
+ array ('y-MMMMM-d ' , '1970-J-1 ' ),
730
+ array ('y-MMMMM-d ' , '1970-S-1 ' ),
731
+
732
+ // standalone 1 char month
733
+ array ('y-LLLLL-d ' , '1970-J-1 ' ),
734
+ array ('y-LLLLL-d ' , '1970-S-1 ' ),
735
+ );
736
+ }
737
+
693
738
/**
694
739
* Just to document the differences between the stub and the intl implementations. The intl can parse
695
740
* any of the tested formats alone. The stub does not implement them as it would be needed to add more
0 commit comments