@@ -97,6 +97,11 @@ class DobTest extends TestCase
97
97
*/
98
98
private $ encoder ;
99
99
100
+ /**
101
+ * @var ResolverInterface
102
+ */
103
+ private $ localeResolver ;
104
+
100
105
/**
101
106
* @inheritDoc
102
107
*/
@@ -116,14 +121,15 @@ protected function setUp(): void
116
121
$ cache ->expects ($ this ->any ())->method ('getFrontend ' )->willReturn ($ frontendCache );
117
122
118
123
$ objectManager = new ObjectManager ($ this );
119
- $ localeResolver = $ this ->getMockForAbstractClass (ResolverInterface::class);
120
- $ localeResolver ->expects ($ this ->any ())
124
+ $ this -> localeResolver = $ this ->getMockForAbstractClass (ResolverInterface::class);
125
+ $ this -> localeResolver ->expects ($ this ->any ())
121
126
->method ('getLocale ' )
122
127
->willReturnCallback (
123
128
function () {
124
129
return $ this ->_locale ;
125
130
}
126
131
);
132
+ $ localeResolver = $ this ->localeResolver ;
127
133
$ timezone = $ objectManager ->getObject (
128
134
Timezone::class,
129
135
['localeResolver ' => $ localeResolver , 'dateFormatterFactory ' => new DateFormatterFactory ()]
@@ -172,7 +178,8 @@ function () use ($timezone, $localeResolver) {
172
178
$ this ->createMock (Date::class),
173
179
$ this ->filterFactory ,
174
180
[],
175
- $ this ->encoder
181
+ $ this ->encoder ,
182
+ $ this ->localeResolver
176
183
);
177
184
}
178
185
@@ -612,13 +619,16 @@ public function testGetHtmlExtraParamsWithRequiredOption()
612
619
/**
613
620
* Tests getTranslatedCalendarConfigJson()
614
621
*
622
+ * @param string $locale
615
623
* @param array $expectedArray
616
624
* @param string $expectedJson
617
625
* @dataProvider getTranslatedCalendarConfigJsonDataProvider
618
626
* @return void
619
627
*/
620
- public function testGetTranslatedCalendarConfigJson (array $ expectedArray , string $ expectedJson ): void
628
+ public function testGetTranslatedCalendarConfigJson (string $ locale , array $ expectedArray , string $ expectedJson ): void
621
629
{
630
+ $ this ->_locale = $ locale ;
631
+
622
632
$ this ->encoder ->expects ($ this ->once ())
623
633
->method ('encode ' )
624
634
->with ($ expectedArray )
@@ -639,6 +649,7 @@ public function getTranslatedCalendarConfigJsonDataProvider()
639
649
{
640
650
return [
641
651
[
652
+ 'locale ' => 'en_US ' ,
642
653
'expectedArray ' => [
643
654
'closeText ' => 'Done ' ,
644
655
'prevText ' => 'Prev ' ,
@@ -653,6 +664,22 @@ public function getTranslatedCalendarConfigJsonDataProvider()
653
664
],
654
665
'expectedJson ' => '{"closeText":"Done","prevText":"Prev","nextText":"Next","currentText":"Today","monthNames":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthNamesShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"dayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"dayNamesShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"dayNamesMin":["Su","Mo","Tu","We","Th","Fr","Sa"]} '
655
666
],
667
+ [
668
+ 'locale ' => 'de_DE ' ,
669
+ 'expectedArray ' => [
670
+ 'closeText ' => 'Done ' ,
671
+ 'prevText ' => 'Prev ' ,
672
+ 'nextText ' => 'Next ' ,
673
+ 'currentText ' => 'Today ' ,
674
+ 'monthNames ' => ['Januar ' , 'Februar ' , 'März ' , 'April ' , 'Mai ' , 'Juni ' ,
675
+ 'Juli ' , 'August ' , 'September ' , 'Oktober ' , 'November ' , 'Dezember ' ],
676
+ 'monthNamesShort ' => ['Jan. ' , 'Feb. ' , 'März ' , 'Apr. ' , 'Mai ' , 'Juni ' , 'Juli ' , 'Aug. ' , 'Sept. ' , 'Okt. ' , 'Nov. ' , 'Dez. ' ],
677
+ 'dayNames ' => ['Sonntag ' , 'Montag ' , 'Dienstag ' , 'Mittwoch ' , 'Donnerstag ' , 'Freitag ' , 'Samstag ' ],
678
+ 'dayNamesShort ' => ['So. ' , 'Mo. ' , 'Di. ' , 'Mi. ' , 'Do. ' , 'Fr. ' , 'Sa. ' ],
679
+ 'dayNamesMin ' => ['So. ' , 'Mo. ' , 'Di. ' , 'Mi. ' , 'Do. ' , 'Fr. ' , 'Sa. ' ],
680
+ ],
681
+ 'expectedJson ' => '{"closeText":"Done","prevText":"Prev","nextText":"Next","currentText":"Today","monthNames":["Januar","Februar","M\u00e4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],"monthNamesShort":["Jan.","Feb.","M\u00e4rz","Apr.","Mai","Juni","Juli","Aug.","Sept.","Okt.","Nov.","Dez."],"dayNames":["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],"dayNamesShort":["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."],"dayNamesMin":["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."]} '
682
+ ],
656
683
];
657
684
}
658
685
}
0 commit comments