Skip to content

Commit 57c3985

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: add validator translation 99 for Italian language stop using the deprecated at() PHPUnit matcher Fix typehint phpdoc
2 parents 4cf31be + f8c05a9 commit 57c3985

File tree

1 file changed

+64
-81
lines changed

1 file changed

+64
-81
lines changed

Tests/Data/Bundle/Reader/BundleEntryReaderTest.php

Lines changed: 64 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,13 @@ public function testForwardCallToRead()
8080

8181
public function testReadEntireDataFileIfNoIndicesGiven()
8282
{
83-
$this->readerImpl->expects($this->at(0))
83+
$this->readerImpl->expects($this->exactly(2))
8484
->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);
9290

9391
$this->assertSame(self::$mergedData, $this->reader->readEntry(self::RES_DIR, 'en', []));
9492
}
@@ -116,15 +114,13 @@ public function testReadNonExistingEntry()
116114

117115
public function testFallbackIfEntryDoesNotExist()
118116
{
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))
125118
->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);
128124

129125
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
130126
}
@@ -142,15 +138,13 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
142138

143139
public function testFallbackIfLocaleDoesNotExist()
144140
{
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))
151142
->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);
154148

155149
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
156150
}
@@ -185,15 +179,13 @@ public function provideMergeableValues()
185179
public function testMergeDataWithFallbackData($childData, $parentData, $result)
186180
{
187181
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))
194183
->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);
197189
} else {
198190
$this->readerImpl->expects($this->once())
199191
->method('read')
@@ -223,15 +215,16 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re
223215
public function testMergeExistingEntryWithExistingFallbackEntry($childData, $parentData, $result)
224216
{
225217
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))
232219
->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+
);
235228
} else {
236229
$this->readerImpl->expects($this->once())
237230
->method('read')
@@ -247,15 +240,13 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par
247240
*/
248241
public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $parentData, $result)
249242
{
250-
$this->readerImpl->expects($this->at(0))
243+
$this->readerImpl
251244
->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]]);
259250

260251
$this->assertSame($parentData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true));
261252
}
@@ -266,15 +257,13 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $
266257
public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $parentData, $result)
267258
{
268259
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
275261
->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']);
278267
} else {
279268
$this->readerImpl->expects($this->once())
280269
->method('read')
@@ -288,15 +277,13 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
288277
public function testFailIfEntryFoundNeitherInParentNorChild()
289278
{
290279
$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
297281
->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']);
300287

301288
$this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true);
302289
}
@@ -310,15 +297,13 @@ public function testMergeTraversables($childData, $parentData, $result)
310297
$childData = \is_array($childData) ? new \ArrayObject($childData) : $childData;
311298

312299
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
319301
->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]]);
322307
} else {
323308
$this->readerImpl->expects($this->once())
324309
->method('read')
@@ -337,16 +322,14 @@ public function testFollowLocaleAliases($childData, $parentData, $result)
337322
$this->reader->setLocaleAliases(['mo' => 'ro_MD']);
338323

339324
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
347326
->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]]);
350333
} else {
351334
$this->readerImpl->expects($this->once())
352335
->method('read')

0 commit comments

Comments
 (0)