|
36 | 36 | use GraphQL\Type\Definition\ObjectType;
|
37 | 37 | use GraphQL\Type\Definition\ResolveInfo;
|
38 | 38 | use GraphQL\Type\Definition\Type as GraphQLType;
|
| 39 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 40 | +use PHPUnit\Framework\Attributes\IgnoreDeprecations; |
39 | 41 | use PHPUnit\Framework\TestCase;
|
40 | 42 | use Prophecy\Argument;
|
41 | 43 | use Prophecy\PhpUnit\ProphecyTrait;
|
42 | 44 | use Prophecy\Prophecy\ObjectProphecy;
|
43 | 45 | use Psr\Container\ContainerInterface;
|
44 |
| -use Symfony\Component\PropertyInfo\Type; |
| 46 | +use Symfony\Component\PropertyInfo\Type as LegacyType; |
| 47 | +use Symfony\Component\TypeInfo\Type; |
45 | 48 |
|
46 | 49 | /**
|
47 | 50 | * @author Alan Poulain <contact@alanpoulain.eu>
|
@@ -125,7 +128,7 @@ public function testGetResourceObjectTypeOutputClass(): void
|
125 | 128 | $resourceObjectType->config['fields']();
|
126 | 129 | }
|
127 | 130 |
|
128 |
| - #[\PHPUnit\Framework\Attributes\DataProvider('resourceObjectTypeQuerySerializationGroupsProvider')] |
| 131 | + #[DataProvider('resourceObjectTypeQuerySerializationGroupsProvider')] |
129 | 132 | public function testGetResourceObjectTypeQuerySerializationGroups(string $itemSerializationGroup, string $collectionSerializationGroup, Operation $operation, string $shortName): void
|
130 | 133 | {
|
131 | 134 | $resourceMetadata = new ResourceMetadataCollection('resourceClass', [(new ApiResource())->withGraphQlOperations([
|
@@ -622,24 +625,40 @@ public function testGetEnumType(): void
|
622 | 625 | ]), $this->typeBuilder->getEnumType($operation));
|
623 | 626 | }
|
624 | 627 |
|
625 |
| - #[\PHPUnit\Framework\Attributes\DataProvider('typesProvider')] |
626 |
| - public function testIsCollection(Type $type, bool $expectedIsCollection): void |
| 628 | + #[DataProvider('legacyTypesProvider')] |
| 629 | + #[IgnoreDeprecations] |
| 630 | + public function testIsCollectionLegacy(LegacyType $type, bool $expectedIsCollection): void |
627 | 631 | {
|
| 632 | + $this->expectUserDeprecationMessage('Since api-platform/graphql 4.2: The "ApiPlatform\GraphQl\Type\TypeBuilder::isCollection()" method is deprecated and will be removed.'); |
628 | 633 | $this->assertSame($expectedIsCollection, $this->typeBuilder->isCollection($type));
|
629 | 634 | }
|
630 | 635 |
|
| 636 | + public static function legacyTypesProvider(): array |
| 637 | + { |
| 638 | + return [ |
| 639 | + [new LegacyType(LegacyType::BUILTIN_TYPE_BOOL), false], |
| 640 | + [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT), false], |
| 641 | + [new LegacyType(LegacyType::BUILTIN_TYPE_RESOURCE, false, null, false), false], |
| 642 | + [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, null, true), false], |
| 643 | + [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true), false], |
| 644 | + [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, null, new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT)), false], |
| 645 | + [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'className', true), false], |
| 646 | + [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, null, true, null, new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'className')), true], |
| 647 | + [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, null, new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'className')), true], |
| 648 | + ]; |
| 649 | + } |
| 650 | + |
631 | 651 | public static function typesProvider(): array
|
632 | 652 | {
|
633 | 653 | return [
|
634 |
| - [new Type(Type::BUILTIN_TYPE_BOOL), false], |
635 |
| - [new Type(Type::BUILTIN_TYPE_OBJECT), false], |
636 |
| - [new Type(Type::BUILTIN_TYPE_RESOURCE, false, null, false), false], |
637 |
| - [new Type(Type::BUILTIN_TYPE_OBJECT, false, null, true), false], |
638 |
| - [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true), false], |
639 |
| - [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, new Type(Type::BUILTIN_TYPE_OBJECT)), false], |
640 |
| - [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'className', true), false], |
641 |
| - [new Type(Type::BUILTIN_TYPE_OBJECT, false, null, true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'className')), true], |
642 |
| - [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'className')), true], |
| 654 | + [Type::bool(), false], |
| 655 | + [Type::object(), false], |
| 656 | + [Type::resource(), false], |
| 657 | + [Type::collection(Type::object(\Stringable::class)), false], |
| 658 | + [Type::array(), false], |
| 659 | + [Type::array(Type::object()), false], |
| 660 | + [Type::collection(Type::object(\Traversable::class), Type::object(\Stringable::class)), true], |
| 661 | + [Type::array(Type::object(\Stringable::class)), true], |
643 | 662 | ];
|
644 | 663 | }
|
645 | 664 | }
|
0 commit comments