33namespace Drupal \Tests \graphql \Kernel ;
44
55use GraphQL \Deferred ;
6- use Drupal \Core \TypedData \TypedDataManagerInterface ;
7- use Drupal \Core \TypedData \ComplexDataInterface ;
8- use Drupal \Core \TypedData \TypedDataInterface ;
96use Drupal \graphql \GraphQL \Resolver \ResolverInterface ;
107
118/**
@@ -21,6 +18,7 @@ class ResolverBuilderTest extends GraphQLTestBase {
2118 public static $ modules = [
2219 'graphql ' ,
2320 'typed_data ' ,
21+ 'graphql_resolver_builder_test ' ,
2422 ];
2523
2624 /**
@@ -132,38 +130,20 @@ public function testFromArgument() {
132130 * @covers ::fromPath
133131 */
134132 public function testFromPath () {
135- $ manager = $ this ->createMock (TypedDataManagerInterface::class);
136- $ manager ->expects ($ this ->any ())
137- ->method ('getDefinition ' )
138- ->will ($ this ->returnValueMap ([
139- 'tree_mock ' => ['class ' => '\Drupal\Core\TypedData\ComplexDataInterface ' ],
140- ]));
141-
142- $ this ->container ->set ('typed_data_manager ' , $ manager );
143-
144- $ uri = $ this ->prophesize (TypedDataInterface::class);
145- $ uri ->getValue ()->willReturn ('<front> ' );
146-
147- $ path = $ this ->prophesize (ComplexDataInterface::class);
148- $ path ->get ('uri ' )->willReturn ($ uri );
149- $ path ->getValue ()->willReturn ([]);
150-
151- $ tree = $ this ->prophesize (ComplexDataInterface::class);
152- $ tree ->get ('path ' )->willReturn ($ path );
153- $ tree ->getValue ()->willReturn ([]);
154-
155- $ manager ->expects ($ this ->any ())
156- ->method ('create ' )
157- ->willReturn ($ tree ->reveal ());
158-
159- $ this ->mockResolver ('Query ' , 'tree ' , $ this ->builder ->fromValue ([
160- 'path ' => [
161- 'uri ' => '<front> ' ,
162- 'path_name ' => 'Front page ' ,
163- ],
164- ]));
133+ $ manager = $ this ->container ->get ('typed_data_manager ' );
134+ $ tree_definition = $ manager ->createDataDefinition ('tree ' );
135+ /** @var \Drupal\graphql_resolver_builder_test\Plugin\DataType\Tree $right */
136+ $ right = $ manager ->create ($ tree_definition );
137+ $ right ->set ('value ' , 'Front page ' );
138+ /** @var \Drupal\graphql_resolver_builder_test\Plugin\DataType\Tree $tree */
139+ $ tree = $ manager ->create ($ tree_definition );
140+ $ tree ->set ('left ' , [
141+ 'value ' => '<front> ' ,
142+ 'right ' => $ right ,
143+ ]);
165144
166- $ this ->mockResolver ('Tree ' , 'uri ' , $ this ->builder ->fromPath ('tree ' , 'path.uri ' ));
145+ $ this ->mockResolver ('Query ' , 'tree ' , $ this ->builder ->fromValue ($ tree ));
146+ $ this ->mockResolver ('Tree ' , 'uri ' , $ this ->builder ->fromPath ('tree ' , 'left.value ' ));
167147
168148 $ query = <<<GQL
169149 query {
0 commit comments