Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix more tests
  • Loading branch information
dunglas committed Jul 24, 2023
commit b35544578619c038428d8e8945fa77a8310dec0d
5 changes: 4 additions & 1 deletion src/OpenApi/Tests/Serializer/ApiGatewayNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public function testSupportsNormalization(): void
$normalizer = new ApiGatewayNormalizer($normalizerProphecy->reveal());

$this->assertTrue($normalizer->supportsNormalization(OpenApiNormalizer::FORMAT, OpenApi::class));
$this->assertTrue($normalizer->hasCacheableSupportsMethod());

if (!method_exists(Serializer::class, 'getSupportedTypes')) {
$this->assertTrue($normalizer->hasCacheableSupportsMethod());
}
}

public function testNormalize(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Elasticsearch/Serializer/ItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ public function testSetSerializerWithDecoratedNormalizerNotAnInstanceOfSerialize

public function testGetSupportedTypes(): void
{
if (!method_exists(Serializer::class, 'getSupportedTypes')) {
$this->markTestSkipped('Symfony Serializer < 6.3');
}

$this->normalizerProphecy->getSupportedTypes(Argument::any())->willReturn(['*' => true]);

$this->assertEmpty($this->itemNormalizer->getSupportedTypes('json'));
Expand Down
13 changes: 7 additions & 6 deletions tests/Hydra/Serializer/CollectionFiltersNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public function testSupportsNormalization(): void
{
$decoratedProphecy = $this->prophesize(NormalizerInterface::class);
$decoratedProphecy->supportsNormalization('foo', 'abc', Argument::type('array'))->willReturn(true)->shouldBeCalled();
$decoratedProphecy->getSupportedTypes(Argument::any())->willReturn(['*' => true]);
if (!method_exists(Serializer::class, 'getSupportedTypes')) {
if (method_exists(Serializer::class, 'getSupportedTypes')) {
$decoratedProphecy->getSupportedTypes(Argument::any())->willReturn(['*' => true]);
} else {
$decoratedProphecy->willImplement(CacheableSupportsMethodInterface::class);
$decoratedProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled();
}
Expand All @@ -61,10 +62,10 @@ public function testSupportsNormalization(): void
$this->prophesize(ContainerInterface::class)->reveal()
);

$this->assertTrue($normalizer->supportsNormalization('foo', 'abc'));
$this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld'));

if (!method_exists(Serializer::class, 'getSupportedTypes')) {
if (method_exists(Serializer::class, 'getSupportedTypes')) {
$this->assertTrue($normalizer->supportsNormalization('foo', 'abc'));
$this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld'));
} else {
$this->assertTrue($normalizer->hasCacheableSupportsMethod());
}
}
Expand Down
14 changes: 8 additions & 6 deletions tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ public function testSupportsNormalization(): void
{
$decoratedNormalizerProphecy = $this->prophesize(NormalizerInterface::class);
$decoratedNormalizerProphecy->supportsNormalization(Argument::any(), null, Argument::type('array'))->willReturn(true)->shouldBeCalled();
$decoratedNormalizerProphecy->getSupportedTypes('jsonld')->willReturn(['*' => true]);
$decoratedNormalizerProphecy->getSupportedTypes(Argument::any())->willReturn([]);

if (!method_exists(Serializer::class, 'getSupportedTypes')) {
if (method_exists(Serializer::class, 'getSupportedTypes')) {
$decoratedNormalizerProphecy->getSupportedTypes('jsonld')->willReturn(['*' => true]);
$decoratedNormalizerProphecy->getSupportedTypes(Argument::any())->willReturn([]);
} else {
$decoratedNormalizerProphecy->willImplement(CacheableSupportsMethodInterface::class);
$decoratedNormalizerProphecy->hasCacheableSupportsMethod()->willReturn(true)->shouldBeCalled();
}
Expand All @@ -178,10 +179,11 @@ public function testSupportsNormalization(): void

$normalizer = new PartialCollectionViewNormalizer($decoratedNormalizerProphecy->reveal(), 'page', 'pagination', $resourceMetadataFactory->reveal());
$this->assertTrue($normalizer->supportsNormalization(new \stdClass()));
$this->assertEmpty($normalizer->getSupportedTypes('json'));
$this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld'));

if (!method_exists(Serializer::class, 'getSupportedTypes')) {
if (method_exists(Serializer::class, 'getSupportedTypes')) {
$this->assertEmpty($normalizer->getSupportedTypes('json'));
$this->assertSame(['*' => true], $normalizer->getSupportedTypes('jsonld'));
} else {
$this->assertTrue($normalizer->hasCacheableSupportsMethod());
}
}
Expand Down