Skip to content

Commit

Permalink
[Tests] Remove occurrences of withConsecutive()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-daubois authored and nicolas-grekas committed Mar 10, 2023
1 parent b99d83e commit 2371736
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
25 changes: 21 additions & 4 deletions Tests/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,31 @@ private function getKernel(array $bundles, $useDispatcher = false)
$container
->expects($this->exactly(2))
->method('hasParameter')
->withConsecutive(['console.command.ids'], ['console.lazy_command.ids'])
->willReturnOnConsecutiveCalls(true, true)
->willReturnCallback(function (...$args) {
static $series = [
['console.command.ids'],
['console.lazy_command.ids'],
];

$this->assertSame(array_shift($series), $args);

return true;
})
;

$container
->expects($this->exactly(2))
->method('getParameter')
->withConsecutive(['console.lazy_command.ids'], ['console.command.ids'])
->willReturnOnConsecutiveCalls([], [])
->willReturnCallback(function (...$args) {
static $series = [
['console.lazy_command.ids'],
['console.command.ids'],
];

$this->assertSame(array_shift($series), $args);

return [];
})
;

$kernel = $this->createMock(KernelInterface::class);
Expand Down
23 changes: 13 additions & 10 deletions Tests/Translation/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,21 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e

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

$series = [
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
[['messages.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
[['second_resource.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
];

$loader->expects($this->exactly(2))
->method('load')
->withConsecutive(
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
['messages.some_locale.loader', 'some_locale', 'messages'],
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
['second_resource.some_locale.loader', 'some_locale', 'messages']
)
->willReturnOnConsecutiveCalls(
$someCatalogue,
$someCatalogue
);
->willReturnCallback(function (...$args) use (&$series) {
[$expectedArgs, $return] = array_shift($series);
$this->assertSame($expectedArgs, $args);

return $return;
});

$options = [
'resource_files' => ['some_locale' => ['messages.some_locale.loader']],
Expand Down

0 comments on commit 2371736

Please sign in to comment.