Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ parameters:

# Expected, due to backward compatibility
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#"
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#"
- '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#'
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\Serializer\\\\\\\\Serializer' and 'getSupportedTypes' will always evaluate to true\\.#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Metadata\ResourceClassResolverInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\TypeInfo\Type;

class SchemaPropertyMetadataFactoryTest extends TestCase
Expand Down Expand Up @@ -88,10 +87,6 @@ public function testWithCustomOpenApiContextWithoutTypeDefinition(): void

public function testUnionTypeAnyOfIsArray(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
$apiProperty = new ApiProperty(nativeType: Type::union(Type::string(), Type::int()));
$decorated = $this->createMock(PropertyMetadataFactoryInterface::class);
Expand All @@ -115,10 +110,6 @@ public function testUnionTypeAnyOfIsArray(): void
*/
public function testRelationWithGenIdFalseIsEmbeddedInOutputSchema(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
$resourceClassResolver->method('isResourceClass')->willReturn(true);

Expand All @@ -143,10 +134,6 @@ public function testRelationWithGenIdFalseIsEmbeddedInOutputSchema(): void
*/
public function testRelationOnNonResourceParentFollowsReadableLinkInOutputSchema(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
// the parent (DummyWithEnum) is not a resource, the related class (Dummy) is
$resourceClassResolver->method('isResourceClass')->willReturnCallback(static fn (string $class): bool => Dummy::class === $class);
Expand All @@ -170,10 +157,6 @@ public function testRelationOnNonResourceParentFollowsReadableLinkInOutputSchema
*/
public function testNonResourceRelationOnNonResourceParentIsEmbeddedInOutputSchema(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
// neither the parent nor the property type is a resource
$resourceClassResolver->method('isResourceClass')->willReturn(false);
Expand All @@ -195,10 +178,6 @@ public function testNonResourceRelationOnNonResourceParentIsEmbeddedInOutputSche
*/
public function testRelationOnResourceParentStaysIriReference(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
// both the parent and the related class are resources
$resourceClassResolver->method('isResourceClass')->willReturn(true);
Expand All @@ -216,10 +195,6 @@ public function testRelationOnResourceParentStaysIriReference(): void

public function testMixed(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
$apiProperty = new ApiProperty(nativeType: Type::mixed());
$decorated = $this->createMock(PropertyMetadataFactoryInterface::class);
Expand Down
9 changes: 0 additions & 9 deletions src/JsonSchema/Tests/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\TypeInfo\Type;

Expand All @@ -51,10 +50,6 @@ class SchemaFactoryTest extends TestCase

public function testBuildSchemaForNonResourceClass(): void
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);

$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
Expand Down Expand Up @@ -599,10 +594,6 @@ public function testBuildSchemaKeepsPropertyMetadataAlongsideAnIntersectionOfRef
*/
private function buildPropertiesWithReference(string $propertyName, ApiProperty $propertyMetadata): array
{
if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true
$this->markTestSkipped('This test only supports type-info component');
}

$propertyNameCollectionFactory = $this->createStub(PropertyNameCollectionFactoryInterface::class);
$propertyNameCollectionFactory->method('create')->willReturnCallback(
static fn (string $class): PropertyNameCollection => new PropertyNameCollection(
Expand Down
7 changes: 0 additions & 7 deletions tests/Functional/UnionIriCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\UnionIriCollection\Container;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\UnionIriCollection\Foo;
use ApiPlatform\Tests\SetupClassResourcesTrait;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;

final class UnionIriCollectionTest extends ApiTestCase
{
Expand All @@ -36,12 +35,6 @@ public static function getResources(): array

public function testDenormalizeCollectionAcceptsIriOfEachUnionMember(): void
{
// The union-collection IRI guard relies on the native type; the legacy
// property-info path (< 7.1) only keeps the first collection value type.
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
$this->markTestSkipped('Requires symfony/property-info >= 7.1 (native types).');
}

$response = self::createClient()->request('POST', '/union_iri_collection_containers', [
'headers' => ['Content-Type' => 'application/ld+json', 'Accept' => 'application/ld+json'],
'json' => ['attachments' => ['/union_iri_collection_foos/1', '/union_iri_collection_bars/2']],
Expand Down
25 changes: 4 additions & 21 deletions tests/Functional/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyWithCollectDenormalizationErrors;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
use ApiPlatform\Tests\SetupClassResourcesTrait;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;

/**
* Tests denormalization error collection feature.
Expand Down Expand Up @@ -92,35 +91,19 @@ public function testPostWithDenormalizationErrorsCollected(): void
$violationQux = $findViolation('qux');
$this->assertNotNull($violationQux);

if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
$this->assertSame('This value should be of type string.', $violationQux['message']);
} else {
$this->assertSame('This value should be of type null|string.', $violationQux['message']);
}
$this->assertSame('This value should be of type null|string.', $violationQux['message']);

$violationFoo = $findViolation('foo');
$this->assertNotNull($violationFoo);
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
$this->assertSame('This value should be of type bool.', $violationFoo['message']);
} else {
$this->assertSame('This value should be of type bool|null.', $violationFoo['message']);
}
$this->assertSame('This value should be of type bool|null.', $violationFoo['message']);

$violationBar = $findViolation('bar');
$this->assertNotNull($violationBar);
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
$this->assertSame('This value should be of type int.', $violationBar['message']);
} else {
$this->assertSame('This value should be of type int|null.', $violationBar['message']);
}
$this->assertSame('This value should be of type int|null.', $violationBar['message']);

$violationUuid = $findViolation('uuid');
$this->assertNotNull($violationUuid);
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
$this->assertSame('This value should be of type uuid.', $violationUuid['message']);
} else {
$this->assertSame('This value should be of type uuid|null.', $violationUuid['message']);
}
$this->assertSame('This value should be of type uuid|null.', $violationUuid['message']);
$this->assertArrayHasKey('hint', $violationUuid);
$this->assertSame('Invalid UUID string: y', $violationUuid['hint']);

Expand Down
Loading