@@ -80,15 +80,13 @@ public function testForwardCallToRead()
80
80
81
81
public function testReadEntireDataFileIfNoIndicesGiven ()
82
82
{
83
- $ this ->readerImpl ->expects ($ this ->at ( 0 ))
83
+ $ this ->readerImpl ->expects ($ this ->exactly ( 2 ))
84
84
->method ('read ' )
85
- ->with (self ::RES_DIR , 'en ' )
86
- ->willReturn (self ::$ data );
87
-
88
- $ this ->readerImpl ->expects ($ this ->at (1 ))
89
- ->method ('read ' )
90
- ->with (self ::RES_DIR , 'root ' )
91
- ->willReturn (self ::$ fallbackData );
85
+ ->withConsecutive (
86
+ [self ::RES_DIR , 'en ' ],
87
+ [self ::RES_DIR , 'root ' ]
88
+ )
89
+ ->willReturnOnConsecutiveCalls (self ::$ data , self ::$ fallbackData );
92
90
93
91
$ this ->assertSame (self ::$ mergedData , $ this ->reader ->readEntry (self ::RES_DIR , 'en ' , []));
94
92
}
@@ -116,15 +114,13 @@ public function testReadNonExistingEntry()
116
114
117
115
public function testFallbackIfEntryDoesNotExist ()
118
116
{
119
- $ this ->readerImpl ->expects ($ this ->at (0 ))
120
- ->method ('read ' )
121
- ->with (self ::RES_DIR , 'en_GB ' )
122
- ->willReturn (self ::$ data );
123
-
124
- $ this ->readerImpl ->expects ($ this ->at (1 ))
117
+ $ this ->readerImpl ->expects ($ this ->exactly (2 ))
125
118
->method ('read ' )
126
- ->with (self ::RES_DIR , 'en ' )
127
- ->willReturn (self ::$ fallbackData );
119
+ ->withConsecutive (
120
+ [self ::RES_DIR , 'en_GB ' ],
121
+ [self ::RES_DIR , 'en ' ]
122
+ )
123
+ ->willReturnOnConsecutiveCalls (self ::$ data , self ::$ fallbackData );
128
124
129
125
$ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
130
126
}
@@ -142,15 +138,13 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
142
138
143
139
public function testFallbackIfLocaleDoesNotExist ()
144
140
{
145
- $ this ->readerImpl ->expects ($ this ->at (0 ))
146
- ->method ('read ' )
147
- ->with (self ::RES_DIR , 'en_GB ' )
148
- ->willThrowException (new ResourceBundleNotFoundException ());
149
-
150
- $ this ->readerImpl ->expects ($ this ->at (1 ))
141
+ $ this ->readerImpl ->expects ($ this ->exactly (2 ))
151
142
->method ('read ' )
152
- ->with (self ::RES_DIR , 'en ' )
153
- ->willReturn (self ::$ fallbackData );
143
+ ->withConsecutive (
144
+ [self ::RES_DIR , 'en_GB ' ],
145
+ [self ::RES_DIR , 'en ' ]
146
+ )
147
+ ->willReturnOnConsecutiveCalls (self ::$ data , self ::$ fallbackData );
154
148
155
149
$ this ->assertSame ('Lah ' , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Entries ' , 'Bam ' ]));
156
150
}
@@ -185,15 +179,13 @@ public function provideMergeableValues()
185
179
public function testMergeDataWithFallbackData ($ childData , $ parentData , $ result )
186
180
{
187
181
if (null === $ childData || \is_array ($ childData )) {
188
- $ this ->readerImpl ->expects ($ this ->at (0 ))
189
- ->method ('read ' )
190
- ->with (self ::RES_DIR , 'en ' )
191
- ->willReturn ($ childData );
192
-
193
- $ this ->readerImpl ->expects ($ this ->at (1 ))
182
+ $ this ->readerImpl ->expects ($ this ->exactly (2 ))
194
183
->method ('read ' )
195
- ->with (self ::RES_DIR , 'root ' )
196
- ->willReturn ($ parentData );
184
+ ->withConsecutive (
185
+ [self ::RES_DIR , 'en ' ],
186
+ [self ::RES_DIR , 'root ' ]
187
+ )
188
+ ->willReturnOnConsecutiveCalls ($ childData , $ parentData );
197
189
} else {
198
190
$ this ->readerImpl ->expects ($ this ->once ())
199
191
->method ('read ' )
@@ -223,15 +215,16 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re
223
215
public function testMergeExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
224
216
{
225
217
if (null === $ childData || \is_array ($ childData )) {
226
- $ this ->readerImpl ->expects ($ this ->at (0 ))
227
- ->method ('read ' )
228
- ->with (self ::RES_DIR , 'en ' )
229
- ->willReturn (['Foo ' => ['Bar ' => $ childData ]]);
230
-
231
- $ this ->readerImpl ->expects ($ this ->at (1 ))
218
+ $ this ->readerImpl ->expects ($ this ->exactly (2 ))
232
219
->method ('read ' )
233
- ->with (self ::RES_DIR , 'root ' )
234
- ->willReturn (['Foo ' => ['Bar ' => $ parentData ]]);
220
+ ->withConsecutive (
221
+ [self ::RES_DIR , 'en ' ],
222
+ [self ::RES_DIR , 'root ' ]
223
+ )
224
+ ->willReturnOnConsecutiveCalls (
225
+ ['Foo ' => ['Bar ' => $ childData ]],
226
+ ['Foo ' => ['Bar ' => $ parentData ]]
227
+ );
235
228
} else {
236
229
$ this ->readerImpl ->expects ($ this ->once ())
237
230
->method ('read ' )
@@ -247,15 +240,13 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par
247
240
*/
248
241
public function testMergeNonExistingEntryWithExistingFallbackEntry ($ childData , $ parentData , $ result )
249
242
{
250
- $ this ->readerImpl -> expects ( $ this -> at ( 0 ))
243
+ $ this ->readerImpl
251
244
->method ('read ' )
252
- ->with (self ::RES_DIR , 'en_GB ' )
253
- ->willReturn (['Foo ' => 'Baz ' ]);
254
-
255
- $ this ->readerImpl ->expects ($ this ->at (1 ))
256
- ->method ('read ' )
257
- ->with (self ::RES_DIR , 'en ' )
258
- ->willReturn (['Foo ' => ['Bar ' => $ parentData ]]);
245
+ ->withConsecutive (
246
+ [self ::RES_DIR , 'en_GB ' ],
247
+ [self ::RES_DIR , 'en ' ]
248
+ )
249
+ ->willReturnOnConsecutiveCalls (['Foo ' => 'Baz ' ], ['Foo ' => ['Bar ' => $ parentData ]]);
259
250
260
251
$ this ->assertSame ($ parentData , $ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true ));
261
252
}
@@ -266,15 +257,13 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $
266
257
public function testMergeExistingEntryWithNonExistingFallbackEntry ($ childData , $ parentData , $ result )
267
258
{
268
259
if (null === $ childData || \is_array ($ childData )) {
269
- $ this ->readerImpl ->expects ($ this ->at (0 ))
270
- ->method ('read ' )
271
- ->with (self ::RES_DIR , 'en_GB ' )
272
- ->willReturn (['Foo ' => ['Bar ' => $ childData ]]);
273
-
274
- $ this ->readerImpl ->expects ($ this ->at (1 ))
260
+ $ this ->readerImpl
275
261
->method ('read ' )
276
- ->with (self ::RES_DIR , 'en ' )
277
- ->willReturn (['Foo ' => 'Bar ' ]);
262
+ ->withConsecutive (
263
+ [self ::RES_DIR , 'en_GB ' ],
264
+ [self ::RES_DIR , 'en ' ]
265
+ )
266
+ ->willReturnOnConsecutiveCalls (['Foo ' => ['Bar ' => $ childData ]], ['Foo ' => 'Bar ' ]);
278
267
} else {
279
268
$ this ->readerImpl ->expects ($ this ->once ())
280
269
->method ('read ' )
@@ -288,15 +277,13 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
288
277
public function testFailIfEntryFoundNeitherInParentNorChild ()
289
278
{
290
279
$ this ->expectException ('Symfony\Component\Intl\Exception\MissingResourceException ' );
291
- $ this ->readerImpl ->expects ($ this ->at (0 ))
292
- ->method ('read ' )
293
- ->with (self ::RES_DIR , 'en_GB ' )
294
- ->willReturn (['Foo ' => 'Baz ' ]);
295
-
296
- $ this ->readerImpl ->expects ($ this ->at (1 ))
280
+ $ this ->readerImpl
297
281
->method ('read ' )
298
- ->with (self ::RES_DIR , 'en ' )
299
- ->willReturn (['Foo ' => 'Bar ' ]);
282
+ ->withConsecutive (
283
+ [self ::RES_DIR , 'en_GB ' ],
284
+ [self ::RES_DIR , 'en ' ]
285
+ )
286
+ ->willReturnOnConsecutiveCalls (['Foo ' => 'Baz ' ], ['Foo ' => 'Baz ' ]);
300
287
301
288
$ this ->reader ->readEntry (self ::RES_DIR , 'en_GB ' , ['Foo ' , 'Bar ' ], true );
302
289
}
@@ -310,15 +297,13 @@ public function testMergeTraversables($childData, $parentData, $result)
310
297
$ childData = \is_array ($ childData ) ? new \ArrayObject ($ childData ) : $ childData ;
311
298
312
299
if (null === $ childData || $ childData instanceof \ArrayObject) {
313
- $ this ->readerImpl ->expects ($ this ->at (0 ))
314
- ->method ('read ' )
315
- ->with (self ::RES_DIR , 'en_GB ' )
316
- ->willReturn (['Foo ' => ['Bar ' => $ childData ]]);
317
-
318
- $ this ->readerImpl ->expects ($ this ->at (1 ))
300
+ $ this ->readerImpl
319
301
->method ('read ' )
320
- ->with (self ::RES_DIR , 'en ' )
321
- ->willReturn (['Foo ' => ['Bar ' => $ parentData ]]);
302
+ ->withConsecutive (
303
+ [self ::RES_DIR , 'en_GB ' ],
304
+ [self ::RES_DIR , 'en ' ]
305
+ )
306
+ ->willReturnOnConsecutiveCalls (['Foo ' => ['Bar ' => $ childData ]], ['Foo ' => ['Bar ' => $ parentData ]]);
322
307
} else {
323
308
$ this ->readerImpl ->expects ($ this ->once ())
324
309
->method ('read ' )
@@ -337,16 +322,14 @@ public function testFollowLocaleAliases($childData, $parentData, $result)
337
322
$ this ->reader ->setLocaleAliases (['mo ' => 'ro_MD ' ]);
338
323
339
324
if (null === $ childData || \is_array ($ childData )) {
340
- $ this ->readerImpl ->expects ($ this ->at (0 ))
341
- ->method ('read ' )
342
- ->with (self ::RES_DIR , 'ro_MD ' )
343
- ->willReturn (['Foo ' => ['Bar ' => $ childData ]]);
344
-
345
- // Read fallback locale of aliased locale ("ro_MD" -> "ro")
346
- $ this ->readerImpl ->expects ($ this ->at (1 ))
325
+ $ this ->readerImpl
347
326
->method ('read ' )
348
- ->with (self ::RES_DIR , 'ro ' )
349
- ->willReturn (['Foo ' => ['Bar ' => $ parentData ]]);
327
+ ->withConsecutive (
328
+ [self ::RES_DIR , 'ro_MD ' ],
329
+ // Read fallback locale of aliased locale ("ro_MD" -> "ro")
330
+ [self ::RES_DIR , 'ro ' ]
331
+ )
332
+ ->willReturnOnConsecutiveCalls (['Foo ' => ['Bar ' => $ childData ]], ['Foo ' => ['Bar ' => $ parentData ]]);
350
333
} else {
351
334
$ this ->readerImpl ->expects ($ this ->once ())
352
335
->method ('read ' )
0 commit comments