Skip to content

Commit

Permalink
Replace deprecated function "returnCallback" with "willReturnCallback…
Browse files Browse the repository at this point in the history
…" in unit tests
  • Loading branch information
guvra committed Jun 11, 2024
1 parent 4a5b768 commit d568470
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions tests/unit/Converter/ConverterBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,20 @@ private function createBuilder(): ConverterBuilder
$containerMock = $this->createMock(ConverterFactory::class);
$containerMock
->method('create')
->will(
$this->returnCallback(
fn (string $value, array $parameters) => match ($value) {
// Converters used in the context of this unit test
'cache' => $this->createConverter(Cache::class, $parameters),
'chain' => $this->createConverter(Chain::class, $parameters),
'conditional' => $this->createConditionalConverter($parameters),
'faker' => $this->createFakerConverter($parameters),
'mock' => $this->createConverter(ConverterMock::class, $parameters),
'notExists' => throw new RuntimeException($value),
'unique' => $this->createConverter(Unique::class, $parameters),
default => throw new UnexpectedValueException(
sprintf('The converter "%s" was not expected in this unit case.', $value)
),
}
)
->willReturnCallback(
fn (string $value, array $parameters) => match ($value) {
// Converters used in the context of this unit test
'cache' => $this->createConverter(Cache::class, $parameters),
'chain' => $this->createConverter(Chain::class, $parameters),
'conditional' => $this->createConditionalConverter($parameters),
'faker' => $this->createFakerConverter($parameters),
'mock' => $this->createConverter(ConverterMock::class, $parameters),
'notExists' => throw new RuntimeException($value),
'unique' => $this->createConverter(Unique::class, $parameters),
default => throw new UnexpectedValueException(
sprintf('The converter "%s" was not expected in this unit case.', $value)
),
}
);

return new ConverterBuilder($containerMock);
Expand Down

0 comments on commit d568470

Please sign in to comment.