Skip to content

Commit 7bf75e3

Browse files
fix: Use normalisation context when none is provided in ApiTestAssertionsTrait
1 parent 8a35ee2 commit 7bf75e3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public static function assertMatchesResourceCollectionJsonSchema(string $resourc
119119
$operation = $operationName ? (new GetCollection())->withName($operationName) : new GetCollection();
120120
}
121121

122+
$serializationContext = $serializationContext ?? $operation->getNormalizationContext();
123+
122124
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, ($serializationContext ?? []) + [BackwardCompatibleSchemaFactory::SCHEMA_DRAFT4_VERSION => true]);
123125

124126
static::assertMatchesJsonSchema($schema->getArrayCopy());
@@ -134,6 +136,8 @@ public static function assertMatchesResourceItemJsonSchema(string $resourceClass
134136
$operation = $operationName ? (new Get())->withName($operationName) : new Get();
135137
}
136138

139+
$serializationContext = $serializationContext ?? $operation->getNormalizationContext();
140+
137141
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, ($serializationContext ?? []) + [BackwardCompatibleSchemaFactory::SCHEMA_DRAFT4_VERSION => true]);
138142

139143
static::assertMatchesJsonSchema($schema->getArrayCopy());

0 commit comments

Comments
 (0)