@@ -63,9 +63,6 @@ class FieldsBuilderTest extends TestCase
63
63
private ObjectProphecy $ typeBuilderProphecy ;
64
64
private ObjectProphecy $ typeConverterProphecy ;
65
65
private ObjectProphecy $ itemResolverFactoryProphecy ;
66
- private ObjectProphecy $ collectionResolverFactoryProphecy ;
67
- private ObjectProphecy $ itemMutationResolverFactoryProphecy ;
68
- private ObjectProphecy $ itemSubscriptionResolverFactoryProphecy ;
69
66
private ObjectProphecy $ filterLocatorProphecy ;
70
67
private ObjectProphecy $ resourceClassResolverProphecy ;
71
68
private FieldsBuilder $ fieldsBuilder ;
@@ -82,17 +79,14 @@ protected function setUp(): void
82
79
$ this ->typeBuilderProphecy = $ this ->prophesize (ContextAwareTypeBuilderInterface::class);
83
80
$ this ->typeConverterProphecy = $ this ->prophesize (TypeConverterInterface::class);
84
81
$ this ->itemResolverFactoryProphecy = $ this ->prophesize (ResolverFactoryInterface::class);
85
- $ this ->collectionResolverFactoryProphecy = $ this ->prophesize (ResolverFactoryInterface::class);
86
- $ this ->itemMutationResolverFactoryProphecy = $ this ->prophesize (ResolverFactoryInterface::class);
87
- $ this ->itemSubscriptionResolverFactoryProphecy = $ this ->prophesize (ResolverFactoryInterface::class);
88
82
$ this ->filterLocatorProphecy = $ this ->prophesize (ContainerInterface::class);
89
83
$ this ->resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
90
84
$ this ->fieldsBuilder = $ this ->buildFieldsBuilder ();
91
85
}
92
86
93
87
private function buildFieldsBuilder (?AdvancedNameConverterInterface $ advancedNameConverter = null ): FieldsBuilder
94
88
{
95
- return new FieldsBuilder ($ this ->propertyNameCollectionFactoryProphecy ->reveal (), $ this ->propertyMetadataFactoryProphecy ->reveal (), $ this ->resourceMetadataCollectionFactoryProphecy ->reveal (), $ this ->resourceClassResolverProphecy ->reveal (), $ this ->typesContainerProphecy ->reveal (), $ this ->typeBuilderProphecy ->reveal (), $ this ->typeConverterProphecy ->reveal (), $ this ->itemResolverFactoryProphecy ->reveal (), $ this ->collectionResolverFactoryProphecy -> reveal (), $ this -> itemMutationResolverFactoryProphecy -> reveal (), $ this -> itemSubscriptionResolverFactoryProphecy -> reveal (), $ this -> filterLocatorProphecy ->reveal (), new Pagination (), $ advancedNameConverter ?? new CustomConverter (), '__ ' );
89
+ return new FieldsBuilder ($ this ->propertyNameCollectionFactoryProphecy ->reveal (), $ this ->propertyMetadataFactoryProphecy ->reveal (), $ this ->resourceMetadataCollectionFactoryProphecy ->reveal (), $ this ->resourceClassResolverProphecy ->reveal (), $ this ->typesContainerProphecy ->reveal (), $ this ->typeBuilderProphecy ->reveal (), $ this ->typeConverterProphecy ->reveal (), $ this ->itemResolverFactoryProphecy ->reveal (), $ this ->filterLocatorProphecy ->reveal (), new Pagination (), $ advancedNameConverter ?? new CustomConverter (), '__ ' );
96
90
}
97
91
98
92
public function testGetNodeQueryFields (): void
@@ -126,7 +120,7 @@ public function testGetItemQueryFields(string $resourceClass, Operation $operati
126
120
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), false , Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), $ resourceClass , $ resourceClass , null , 0 )->willReturn ($ graphqlType );
127
121
$ this ->typeConverterProphecy ->resolveType (Argument::type ('string ' ))->willReturn (GraphQLType::string ());
128
122
$ this ->typeBuilderProphecy ->isCollection (Argument::type (Type::class))->willReturn (false );
129
- $ this ->itemResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation )->willReturn ($ resolver );
123
+ $ this ->itemResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation, Argument:: any () )->willReturn ($ resolver );
130
124
131
125
$ queryFields = $ this ->fieldsBuilder ->getItemQueryFields ($ resourceClass , $ operation , $ configuration );
132
126
@@ -206,7 +200,7 @@ public function testGetCollectionQueryFields(string $resourceClass, Operation $o
206
200
$ this ->typeConverterProphecy ->resolveType (Argument::type ('string ' ))->willReturn (GraphQLType::string ());
207
201
$ this ->typeBuilderProphecy ->isCollection (Argument::type (Type::class))->willReturn (true );
208
202
$ this ->typeBuilderProphecy ->getPaginatedCollectionType ($ graphqlType , $ operation )->willReturn ($ graphqlType );
209
- $ this ->collectionResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation )->willReturn ($ resolver );
203
+ $ this ->itemResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation, Argument:: any () )->willReturn ($ resolver );
210
204
$ this ->filterLocatorProphecy ->has ('my_filter ' )->willReturn (true );
211
205
$ filterProphecy = $ this ->prophesize (FilterInterface::class);
212
206
$ filterProphecy ->getDescription ($ resourceClass )->willReturn ([
@@ -356,7 +350,7 @@ public function testGetMutationFields(string $resourceClass, Operation $operatio
356
350
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), false , Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), $ resourceClass , $ resourceClass , null , 0 )->willReturn ($ graphqlType );
357
351
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), true , Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), $ resourceClass , $ resourceClass , null , 0 )->willReturn ($ inputGraphqlType );
358
352
$ this ->typeBuilderProphecy ->isCollection (Argument::type (Type::class))->willReturn (false );
359
- $ this ->itemMutationResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation )->willReturn ($ mutationResolver );
353
+ $ this ->itemResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation, Argument:: any () )->willReturn ($ mutationResolver );
360
354
361
355
$ mutationFields = $ this ->fieldsBuilder ->getMutationFields ($ resourceClass , $ operation );
362
356
@@ -417,7 +411,7 @@ public function testGetSubscriptionFields(string $resourceClass, Operation $oper
417
411
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), true , Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), $ resourceClass , $ resourceClass , null , 0 )->willReturn ($ inputGraphqlType );
418
412
$ this ->typeBuilderProphecy ->isCollection (Argument::type (Type::class))->willReturn (false );
419
413
$ this ->resourceMetadataCollectionFactoryProphecy ->create ($ resourceClass )->willReturn (new ResourceMetadataCollection ($ resourceClass , [(new ApiResource ())->withGraphQlOperations ([$ operation ->getName () => $ operation ])]));
420
- $ this ->itemSubscriptionResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation )->willReturn ($ subscriptionResolver );
414
+ $ this ->itemResolverFactoryProphecy ->__invoke ($ resourceClass , $ resourceClass , $ operation, Argument:: any () )->willReturn ($ subscriptionResolver );
421
415
422
416
$ subscriptionFields = $ this ->fieldsBuilder ->getSubscriptionFields ($ resourceClass , $ operation );
423
417
@@ -489,14 +483,14 @@ public function testGetResourceObjectTypeFields(string $resourceClass, Operation
489
483
490
484
if ('propertyObject ' === $ propertyName ) {
491
485
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), Argument::type ('bool ' ), Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), 'objectClass ' , $ resourceClass , $ propertyName , $ depth + 1 )->willReturn (new ObjectType (['name ' => 'objectType ' , 'fields ' => []]));
492
- $ this ->itemResolverFactoryProphecy ->__invoke ('objectClass ' , $ resourceClass , $ operation )->willReturn (static function (): void {
486
+ $ this ->itemResolverFactoryProphecy ->__invoke ('objectClass ' , $ resourceClass , $ operation, Argument:: any () )->willReturn (static function (): void {
493
487
});
494
488
}
495
489
if ('propertyNestedResource ' === $ propertyName ) {
496
490
$ nestedResourceQueryOperation = new Query ();
497
491
$ this ->resourceMetadataCollectionFactoryProphecy ->create ('nestedResourceClass ' )->willReturn (new ResourceMetadataCollection ('nestedResourceClass ' , [(new ApiResource ())->withGraphQlOperations (['item_query ' => $ nestedResourceQueryOperation ])]));
498
492
$ this ->typeConverterProphecy ->convertType (Argument::type (Type::class), Argument::type ('bool ' ), Argument::that (static fn (Operation $ arg ): bool => $ arg ->getName () === $ operation ->getName ()), 'nestedResourceClass ' , $ resourceClass , $ propertyName , $ depth + 1 )->willReturn (new ObjectType (['name ' => 'objectType ' , 'fields ' => []]));
499
- $ this ->itemResolverFactoryProphecy ->__invoke ('nestedResourceClass ' , $ resourceClass , $ nestedResourceQueryOperation )->willReturn (static function (): void {
493
+ $ this ->itemResolverFactoryProphecy ->__invoke ('nestedResourceClass ' , $ resourceClass , $ nestedResourceQueryOperation, Argument:: any () )->willReturn (static function (): void {
500
494
});
501
495
}
502
496
}
0 commit comments