Skip to content

Commit 4cc8645

Browse files
minor #49621 [Tests] Remove occurrences of withConsecutive() (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Tests] Remove occurrences of `withConsecutive()` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - `withConsecutive()` has been deprecated in PHPUnit 9.6 and removed in PHP 10 (sebastianbergmann/phpunit#4564). This PR aims at starting the work to remove these occurrences. There is unfortunately no given migration path, and this requires manual work. I'll create a meta issue referencing remaining occurrences if this one's merged, to keep track. Some seems pretty hard to remove. cc `@OskarStark` this might interest you, as we worked a lot on tests lately 😄 Commits ------- 2047763649 [Tests] Remove occurrences of `withConsecutive()`
2 parents 71baf6b + ad06a79 commit 4cc8645

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

Tests/Console/ApplicationTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,31 @@ private function getKernel(array $bundles, $useDispatcher = false)
258258
$container
259259
->expects($this->exactly(2))
260260
->method('hasParameter')
261-
->withConsecutive(['console.command.ids'], ['console.lazy_command.ids'])
262-
->willReturnOnConsecutiveCalls(true, true)
261+
->willReturnCallback(function (...$args) {
262+
static $series = [
263+
['console.command.ids'],
264+
['console.lazy_command.ids'],
265+
];
266+
267+
$this->assertSame(array_shift($series), $args);
268+
269+
return true;
270+
})
263271
;
272+
264273
$container
265274
->expects($this->exactly(2))
266275
->method('getParameter')
267-
->withConsecutive(['console.lazy_command.ids'], ['console.command.ids'])
268-
->willReturnOnConsecutiveCalls([], [])
276+
->willReturnCallback(function (...$args) {
277+
static $series = [
278+
['console.lazy_command.ids'],
279+
['console.command.ids'],
280+
];
281+
282+
$this->assertSame(array_shift($series), $args);
283+
284+
return [];
285+
})
269286
;
270287

271288
$kernel = $this->createMock(KernelInterface::class);

Tests/Translation/TranslatorTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,21 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e
148148

149149
$loader = $this->createMock(LoaderInterface::class);
150150

151+
$series = [
152+
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
153+
[['messages.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
154+
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
155+
[['second_resource.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
156+
];
157+
151158
$loader->expects($this->exactly(2))
152159
->method('load')
153-
->withConsecutive(
154-
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
155-
['messages.some_locale.loader', 'some_locale', 'messages'],
156-
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
157-
['second_resource.some_locale.loader', 'some_locale', 'messages']
158-
)
159-
->willReturnOnConsecutiveCalls(
160-
$someCatalogue,
161-
$someCatalogue
162-
);
160+
->willReturnCallback(function (...$args) use (&$series) {
161+
[$expectedArgs, $return] = array_shift($series);
162+
$this->assertSame($expectedArgs, $args);
163+
164+
return $return;
165+
});
163166

164167
$options = [
165168
'resource_files' => ['some_locale' => ['messages.some_locale.loader']],

0 commit comments

Comments
 (0)