Skip to content

Commit 78ad216

Browse files
committed
ci: symfony 7.3 deprecations
1 parent 84b9679 commit 78ad216

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

src/Hydra/phpunit.baseline.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<files version="1">
3+
<file path="vendor/symfony/property-info/Type.php">
4+
<line number="14" hash="4ae33c31826c25b82a796a6fec924f56f5dc32ac">
5+
<issue><![CDATA[Since symfony/property-info 7.3: The "Symfony\Component\PropertyInfo\Type" class is deprecated. Use "Symfony\Component\TypeInfo\Type" class from "symfony/type-info" instead.]]></issue>
6+
</line>
7+
</file>
8+
</files>

src/Hydra/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<directory>./Tests/</directory>
99
</testsuite>
1010
</testsuites>
11-
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="false" >
11+
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="false" baseline="phpunit.baseline.xml">
1212
<deprecationTrigger>
1313
<function>trigger_deprecation</function>
1414
</deprecationTrigger>

src/JsonApi/Tests/Serializer/ItemNormalizerTest.php

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use PHPUnit\Framework\TestCase;
3434
use Prophecy\Argument;
3535
use Prophecy\PhpUnit\ProphecyTrait;
36-
use Symfony\Component\HttpFoundation\EventStreamResponse;
3736
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
3837
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
3938
use Symfony\Component\PropertyInfo\Type;
@@ -133,14 +132,16 @@ public function testNormalizeCircularReference(): void
133132
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
134133
$resourceClassResolverProphecy->isResourceClass(CircularReference::class)->willReturn(true);
135134
$resourceClassResolverProphecy->getResourceClass($circularReferenceEntity, null)->willReturn(CircularReference::class);
136-
$resourceClassResolverProphecy->getResourceClass($circularReferenceEntity, CircularReference::class)->willReturn(CircularReference::class);
137-
$resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
135+
$resourceClassResolverProphecy->getResourceClass(null, CircularReference::class)->willReturn(CircularReference::class);
138136

139137
$resourceMetadataCollectionFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
140138
$resourceMetadataCollectionFactoryProphecy->create(CircularReference::class)->willReturn(new ResourceMetadataCollection('CircularReference'));
141139

140+
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
141+
$propertyNameCollectionFactoryProphecy->create(CircularReference::class, [])->willReturn(new PropertyNameCollection());
142+
142143
$normalizer = new ItemNormalizer(
143-
$this->prophesize(PropertyNameCollectionFactoryInterface::class)->reveal(),
144+
$propertyNameCollectionFactoryProphecy->reveal(),
144145
$this->prophesize(PropertyMetadataFactoryInterface::class)->reveal(),
145146
$iriConverterProphecy->reveal(),
146147
$resourceClassResolverProphecy->reveal(),
@@ -153,13 +154,23 @@ public function testNormalizeCircularReference(): void
153154

154155
$normalizer->setSerializer($this->prophesize(SerializerInterface::class)->reveal());
155156

156-
// Symfony >= 7.3
157-
$splObject = class_exists(EventStreamResponse::class) ? spl_object_id($circularReferenceEntity) : spl_object_hash($circularReferenceEntity);
158-
$context = [
159-
'circular_reference_limit' => 2,
160-
'circular_reference_limit_counters' => [$splObject => 2],
161-
'cache_error' => function (): void {},
162-
];
157+
$circularReferenceLimit = 2;
158+
if (!interface_exists(AdvancedNameConverterInterface::class) && method_exists($normalizer, 'setCircularReferenceLimit')) {
159+
$normalizer->setCircularReferenceLimit($circularReferenceLimit);
160+
161+
$context = [
162+
'api_empty_resource_as_iri' => true,
163+
'circular_reference_limit' => [spl_object_hash($circularReferenceEntity) => 2],
164+
'cache_error' => function (): void {},
165+
];
166+
} else {
167+
$context = [
168+
'api_empty_resource_as_iri' => true,
169+
'circular_reference_limit' => $circularReferenceLimit,
170+
'circular_reference_limit_counters' => [spl_object_hash($circularReferenceEntity) => 2],
171+
'cache_error' => function (): void {},
172+
];
173+
}
163174

164175
$this->assertSame('/circular_references/1', $normalizer->normalize($circularReferenceEntity, ItemNormalizer::FORMAT, $context));
165176
}
@@ -282,13 +293,17 @@ public function testDenormalize(): void
282293
$serializerProphecy->willImplement(NormalizerInterface::class);
283294

284295
$resourceMetadataCollectionFactory = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
285-
$resourceMetadataCollectionFactory->create(Dummy::class)->willReturn(new ResourceMetadataCollection(Dummy::class, [
286-
(new ApiResource())->withOperations(new Operations([new Get(name: 'get')])),
287-
]
296+
$resourceMetadataCollectionFactory->create(Dummy::class)->willReturn(new ResourceMetadataCollection(
297+
Dummy::class,
298+
[
299+
(new ApiResource())->withOperations(new Operations([new Get(name: 'get')])),
300+
]
288301
));
289-
$resourceMetadataCollectionFactory->create(RelatedDummy::class)->willReturn(new ResourceMetadataCollection(RelatedDummy::class, [
290-
(new ApiResource())->withOperations(new Operations([new Get(name: 'get')])),
291-
]
302+
$resourceMetadataCollectionFactory->create(RelatedDummy::class)->willReturn(new ResourceMetadataCollection(
303+
RelatedDummy::class,
304+
[
305+
(new ApiResource())->withOperations(new Operations([new Get(name: 'get')])),
306+
]
292307
));
293308

294309
$normalizer = new ItemNormalizer(
@@ -461,7 +476,8 @@ public function testDenormalizeRelationIsNotResourceLinkage(): void
461476
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
462477
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', [])->willReturn(
463478
(new ApiProperty())->withBuiltinTypes([
464-
new Type(Type::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class), ])->withReadable(false)->withWritable(true)->withReadableLink(false)->withWritableLink(false)
479+
new Type(Type::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class),
480+
])->withReadable(false)->withWritable(true)->withReadableLink(false)->withWritableLink(false)
465481
);
466482

467483
$iriConverterProphecy = $this->prophesize(IriConverterInterface::class);

0 commit comments

Comments
 (0)