@@ -84,11 +84,18 @@ public function testReadEntireDataFileIfNoIndicesGiven()
8484 {
8585 $ this ->readerImpl ->expects ($ this ->exactly (2 ))
8686 ->method ('read ' )
87- ->withConsecutive (
88- [self ::RES_DIR , 'en ' ],
89- [self ::RES_DIR , 'root ' ]
90- )
91- ->willReturnOnConsecutiveCalls (self ::DATA , self ::FALLBACK_DATA );
87+ ->willReturnCallback (function (...$ args ) {
88+ static $ series = [
89+ [[self ::RES_DIR , 'en ' ], self ::DATA ],
90+ [[self ::RES_DIR , 'root ' ], self ::FALLBACK_DATA ],
91+ ];
92+
93+ [$ expectedArgs , $ return ] = array_shift ($ series );
94+ $ this ->assertSame ($ expectedArgs , $ args );
95+
96+ return $ return ;
97+ })
98+ ;
9299
93100 $ this ->assertSame (self ::MERGED_DATA , $ this ->reader ->readEntry (self ::RES_DIR , 'en ' , []));
94101 }
@@ -118,11 +125,18 @@ public function testFallbackIfEntryDoesNotExist()
118125 {
119126 $ this ->readerImpl ->expects ($ this ->exactly (2 ))
120127 ->method ('read ' )
121- ->withConsecutive (
122- [self ::RES_DIR , 'en_GB ' ],
123- [self ::RES_DIR , 'en ' ]
124- )
125- ->willReturnOnConsecutiveCalls (self ::DATA , self ::FALLBACK_DATA );
128+ ->willReturnCallback (function (...$ args ) {
129+ static $ series = [
130+ [[self ::RES_DIR , 'en_GB ' ], self ::DATA ],
131+ [[self ::RES_DIR , 'en ' ], self ::FALLBACK_DATA ],
132+ ];
133+
134+ [$ expectedArgs , $ return ] = array_shift ($ series );
135+ $ this ->assertSame ($ expectedArgs , $ args );
136+
137+ return $ return ;
138+ })
139+ ;
126140
127141 $ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
128142 }
@@ -140,16 +154,25 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
140154
141155 public function testFallbackIfLocaleDoesNotExist ()
142156 {
157+ $ exception = new ResourceBundleNotFoundException ();
158+ $ series = [
159+ [[self ::RES_DIR , 'en_GB ' ], $ exception ],
160+ [[self ::RES_DIR , 'en ' ], self ::FALLBACK_DATA ],
161+ ];
162+
143163 $ this ->readerImpl ->expects ($ this ->exactly (2 ))
144164 ->method ('read ' )
145- ->withConsecutive (
146- [self ::RES_DIR , 'en_GB ' ],
147- [self ::RES_DIR , 'en ' ]
148- )
149- ->willReturnOnConsecutiveCalls (
150- $ this ->throwException (new ResourceBundleNotFoundException ()),
151- self ::FALLBACK_DATA
152- );
165+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
166+ [$ expectedArgs , $ return ] = array_shift ($ series );
167+ $ this ->assertSame ($ expectedArgs , $ args );
168+
169+ if ($ return instanceof \Exception) {
170+ throw $ return ;
171+ }
172+
173+ return $ return ;
174+ })
175+ ;
153176
154177 $ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
155178 }
@@ -184,13 +207,20 @@ public static function provideMergeableValues()
184207 public function testMergeDataWithFallbackData ($ childData , $ parentData , $ result )
185208 {
186209 if (null === $ childData || \is_array ($ childData )) {
210+ $ series = [
211+ [[self ::RES_DIR , 'en ' ], $ childData ],
212+ [[self ::RES_DIR , 'root ' ], $ parentData ],
213+ ];
214+
187215 $ this ->readerImpl ->expects ($ this ->exactly (2 ))
188216 ->method ('read ' )
189- ->withConsecutive (
190- [self ::RES_DIR , 'en ' ],
191- [self ::RES_DIR , 'root ' ]
192- )
193- ->willReturnOnConsecutiveCalls ($ childData , $ parentData );
217+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
218+ [$ expectedArgs , $ return ] = array_shift ($ series );
219+ $ this ->assertSame ($ expectedArgs , $ args );
220+
221+ return $ return ;
222+ })
223+ ;
194224 } else {
195225 $ this ->readerImpl ->expects ($ this ->once ())
196226 ->method ('read ' )
@@ -220,16 +250,20 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re
220250 public function testMergeExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
221251 {
222252 if (null === $ childData || \is_array ($ childData )) {
253+ $ series = [
254+ [[self ::RES_DIR , 'en ' ], ['Foo ' => ['Bar ' => $ childData ]]],
255+ [[self ::RES_DIR , 'root ' ], ['Foo ' => ['Bar ' => $ parentData ]]],
256+ ];
257+
223258 $ this ->readerImpl ->expects ($ this ->exactly (2 ))
224259 ->method ('read ' )
225- ->withConsecutive (
226- [self ::RES_DIR , 'en ' ],
227- [self ::RES_DIR , 'root ' ]
228- )
229- ->willReturnOnConsecutiveCalls (
230- ['Foo ' => ['Bar ' => $ childData ]],
231- ['Foo ' => ['Bar ' => $ parentData ]]
232- );
260+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
261+ [$ expectedArgs , $ return ] = array_shift ($ series );
262+ $ this ->assertSame ($ expectedArgs , $ args );
263+
264+ return $ return ;
265+ })
266+ ;
233267 } else {
234268 $ this ->readerImpl ->expects ($ this ->once ())
235269 ->method ('read ' )
@@ -245,13 +279,19 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par
245279 */
246280 public function testMergeNonExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
247281 {
282+ $ series = [
283+ [[self ::RES_DIR , 'en_GB ' ], ['Foo ' => 'Baz ' ]],
284+ [[self ::RES_DIR , 'en ' ], ['Foo ' => ['Bar ' => $ parentData ]]],
285+ ];
286+
248287 $ this ->readerImpl
249288 ->method ('read ' )
250- ->withConsecutive (
251- [self ::RES_DIR , 'en_GB ' ],
252- [self ::RES_DIR , 'en ' ]
253- )
254- ->willReturnOnConsecutiveCalls (['Foo ' => 'Baz ' ], ['Foo ' => ['Bar ' => $ parentData ]]);
289+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
290+ [$ expectedArgs , $ return ] = array_shift ($ series );
291+
292+ return $ expectedArgs === $ args ? $ return : null ;
293+ })
294+ ;
255295
256296 $ this ->assertSame ($ parentData , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true ));
257297 }
@@ -262,13 +302,19 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $
262302 public function testMergeExistingEntryWithNonExistingFallbackEntry ($ childData , $ parentData , $ result )
263303 {
264304 if (null === $ childData || \is_array ($ childData )) {
305+ $ series = [
306+ [[self ::RES_DIR , 'en_GB ' ], ['Foo ' => ['Bar ' => $ childData ]]],
307+ [[self ::RES_DIR , 'en ' ], ['Foo ' => 'Bar ' ]],
308+ ];
309+
265310 $ this ->readerImpl
266311 ->method ('read ' )
267- ->withConsecutive (
268- [self ::RES_DIR , 'en_GB ' ],
269- [self ::RES_DIR , 'en ' ]
270- )
271- ->willReturnOnConsecutiveCalls (['Foo ' => ['Bar ' => $ childData ]], ['Foo ' => 'Bar ' ]);
312+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
313+ [$ expectedArgs , $ return ] = array_shift ($ series );
314+
315+ return $ expectedArgs === $ args ? $ return : null ;
316+ })
317+ ;
272318 } else {
273319 $ this ->readerImpl ->expects ($ this ->once ())
274320 ->method ('read ' )
@@ -282,13 +328,20 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
282328 public function testFailIfEntryFoundNeitherInParentNorChild ()
283329 {
284330 $ this ->expectException (MissingResourceException::class);
331+
285332 $ this ->readerImpl
286333 ->method ('read ' )
287- ->withConsecutive (
288- [self ::RES_DIR , 'en_GB ' ],
289- [self ::RES_DIR , 'en ' ]
290- )
291- ->willReturnOnConsecutiveCalls (['Foo ' => 'Baz ' ], ['Foo ' => 'Bar ' ]);
334+ ->willReturnCallback (function (...$ args ) {
335+ static $ series = [
336+ [[self ::RES_DIR , 'en_GB ' ], ['Foo ' => 'Baz ' ]],
337+ [[self ::RES_DIR , 'en ' ], ['Foo ' => 'Bar ' ]],
338+ ];
339+
340+ [$ expectedArgs , $ return ] = array_shift ($ series );
341+
342+ return $ expectedArgs === $ args ? $ return : null ;
343+ })
344+ ;
292345
293346 $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true );
294347 }
@@ -302,13 +355,19 @@ public function testMergeTraversables($childData, $parentData, $result)
302355 $ childData = \is_array ($ childData ) ? new \ArrayObject ($ childData ) : $ childData ;
303356
304357 if (null === $ childData || $ childData instanceof \ArrayObject) {
358+ $ series = [
359+ [[self ::RES_DIR , 'en_GB ' ], ['Foo ' => ['Bar ' => $ childData ]]],
360+ [[self ::RES_DIR , 'en ' ], ['Foo ' => ['Bar ' => $ parentData ]]],
361+ ];
362+
305363 $ this ->readerImpl
306364 ->method ('read ' )
307- ->withConsecutive (
308- [self ::RES_DIR , 'en_GB ' ],
309- [self ::RES_DIR , 'en ' ]
310- )
311- ->willReturnOnConsecutiveCalls (['Foo ' => ['Bar ' => $ childData ]], ['Foo ' => ['Bar ' => $ parentData ]]);
365+ ->willReturnCallback (function (...$ args ) use (&$ series ) {
366+ [$ expectedArgs , $ return ] = array_shift ($ series );
367+
368+ return $ expectedArgs === $ args ? $ return : null ;
369+ })
370+ ;
312371 } else {
313372 $ this ->readerImpl ->expects ($ this ->once ())
314373 ->method ('read ' )
@@ -327,14 +386,20 @@ public function testFollowLocaleAliases($childData, $parentData, $result)
327386 $ this ->reader ->setLocaleAliases (['mo ' => 'ro_MD ' ]);
328387
329388 if (null === $ childData || \is_array ($ childData )) {
389+ $ series = [
390+ [[self ::RES_DIR , 'ro_MD ' ], ['Foo ' => ['Bar ' => $ childData ]]],
391+ // Read fallback locale of aliased locale ("ro_MD" -> "ro")
392+ [[self ::RES_DIR , 'ro ' ], ['Foo ' => ['Bar ' => $ parentData ]]],
393+ ];
394+
330395 $ this ->readerImpl
331396 ->method ('read ' )
332- ->withConsecutive (
333- [self :: RES_DIR , ' ro_MD ' ],
334- // Read fallback locale of aliased locale ("ro_MD" -> "ro")
335- [ self :: RES_DIR , ' ro ' ]
336- )
337- -> willReturnOnConsecutiveCalls ([ ' Foo ' => [ ' Bar ' => $ childData ]], [ ' Foo ' => [ ' Bar ' => $ parentData ]]) ;
397+ ->willReturnCallback ( function (... $ args ) use (& $ series ) {
398+ [$ expectedArgs , $ return ] = array_shift ( $ series );
399+
400+ return $ expectedArgs === $ args ? $ return : null ;
401+ } )
402+ ;
338403 } else {
339404 $ this ->readerImpl ->expects ($ this ->once ())
340405 ->method ('read ' )
0 commit comments