Skip to content

Commit

Permalink
minor #54645 [Serializer] fix tests (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 7.1 branch.

Discussion
----------

[Serializer] fix tests

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

Commits
-------

31da707 fix tests
  • Loading branch information
nicolas-grekas committed Apr 18, 2024
2 parents 1e2c337 + 31da707 commit d283e72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function attributeProvider()
public function testDenormalizeWithContext()
{
$nameConverter = new CamelCaseToSnakeCaseNameConverter(null, true);
$denormalizedValue = $nameConverter->denormalize('last_name', context: [CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES]);
$denormalizedValue = $nameConverter->denormalize('last_name', null, null, [CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES]);

$this->assertSame($denormalizedValue, 'lastName');
}
Expand All @@ -71,6 +71,6 @@ public function testErrorDenormalizeWithContext()
$nameConverter = new CamelCaseToSnakeCaseNameConverter(null, true);

$this->expectException(UnexpectedPropertyException::class);
$nameConverter->denormalize('lastName', context: [CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES => true]);
$nameConverter->denormalize('lastName', null, null, [CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES => true]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ public static function getNormalizerWithCustomNameConverter()
{
$extractor = new PhpDocExtractor();
$nameConverter = new class() implements NameConverterInterface {
public function normalize(string $propertyName): string
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
return ucfirst($propertyName);
}

public function denormalize(string $propertyName): string
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
return lcfirst($propertyName);
}
Expand Down

0 comments on commit d283e72

Please sign in to comment.