@@ -84,11 +84,18 @@ public function testReadEntireDataFileIfNoIndicesGiven()
84
84
{
85
85
$ this ->readerImpl ->expects ($ this ->exactly (2 ))
86
86
->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
+ ;
92
99
93
100
$ this ->assertSame (self ::MERGED_DATA , $ this ->reader ->readEntry (self ::RES_DIR , 'en ' , []));
94
101
}
@@ -118,11 +125,18 @@ public function testFallbackIfEntryDoesNotExist()
118
125
{
119
126
$ this ->readerImpl ->expects ($ this ->exactly (2 ))
120
127
->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
+ ;
126
140
127
141
$ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
128
142
}
@@ -140,16 +154,25 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
140
154
141
155
public function testFallbackIfLocaleDoesNotExist ()
142
156
{
157
+ $ exception = new ResourceBundleNotFoundException ();
158
+ $ series = [
159
+ [[self ::RES_DIR , 'en_GB ' ], $ exception ],
160
+ [[self ::RES_DIR , 'en ' ], self ::FALLBACK_DATA ],
161
+ ];
162
+
143
163
$ this ->readerImpl ->expects ($ this ->exactly (2 ))
144
164
->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
+ ;
153
176
154
177
$ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
155
178
}
@@ -184,13 +207,20 @@ public static function provideMergeableValues()
184
207
public function testMergeDataWithFallbackData ($ childData , $ parentData , $ result )
185
208
{
186
209
if (null === $ childData || \is_array ($ childData )) {
210
+ $ series = [
211
+ [[self ::RES_DIR , 'en ' ], $ childData ],
212
+ [[self ::RES_DIR , 'root ' ], $ parentData ],
213
+ ];
214
+
187
215
$ this ->readerImpl ->expects ($ this ->exactly (2 ))
188
216
->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
+ ;
194
224
} else {
195
225
$ this ->readerImpl ->expects ($ this ->once ())
196
226
->method ('read ' )
@@ -220,16 +250,20 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re
220
250
public function testMergeExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
221
251
{
222
252
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
+
223
258
$ this ->readerImpl ->expects ($ this ->exactly (2 ))
224
259
->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
+ ;
233
267
} else {
234
268
$ this ->readerImpl ->expects ($ this ->once ())
235
269
->method ('read ' )
@@ -245,13 +279,19 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par
245
279
*/
246
280
public function testMergeNonExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
247
281
{
282
+ $ series = [
283
+ [[self ::RES_DIR , 'en_GB ' ], ['Foo ' => 'Baz ' ]],
284
+ [[self ::RES_DIR , 'en ' ], ['Foo ' => ['Bar ' => $ parentData ]]],
285
+ ];
286
+
248
287
$ this ->readerImpl
249
288
->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
+ ;
255
295
256
296
$ this ->assertSame ($ parentData , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true ));
257
297
}
@@ -262,13 +302,19 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $
262
302
public function testMergeExistingEntryWithNonExistingFallbackEntry ($ childData , $ parentData , $ result )
263
303
{
264
304
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
+
265
310
$ this ->readerImpl
266
311
->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
+ ;
272
318
} else {
273
319
$ this ->readerImpl ->expects ($ this ->once ())
274
320
->method ('read ' )
@@ -282,13 +328,20 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
282
328
public function testFailIfEntryFoundNeitherInParentNorChild ()
283
329
{
284
330
$ this ->expectException (MissingResourceException::class);
331
+
285
332
$ this ->readerImpl
286
333
->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
+ ;
292
345
293
346
$ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true );
294
347
}
@@ -302,13 +355,19 @@ public function testMergeTraversables($childData, $parentData, $result)
302
355
$ childData = \is_array ($ childData ) ? new \ArrayObject ($ childData ) : $ childData ;
303
356
304
357
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
+
305
363
$ this ->readerImpl
306
364
->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
+ ;
312
371
} else {
313
372
$ this ->readerImpl ->expects ($ this ->once ())
314
373
->method ('read ' )
@@ -327,14 +386,20 @@ public function testFollowLocaleAliases($childData, $parentData, $result)
327
386
$ this ->reader ->setLocaleAliases (['mo ' => 'ro_MD ' ]);
328
387
329
388
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
+
330
395
$ this ->readerImpl
331
396
->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
+ ;
338
403
} else {
339
404
$ this ->readerImpl ->expects ($ this ->once ())
340
405
->method ('read ' )
0 commit comments