Conditions | 1 |
Paths | 1 |
Total Lines | 29 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function testPromiseToExecute() : void |
||
18 | { |
||
19 | $promiseAdapter = new SyncPromiseAdapter(); |
||
20 | $schema = new Schema( |
||
21 | [ |
||
22 | 'query' => new ObjectType( |
||
23 | [ |
||
24 | 'name' => 'Query', |
||
25 | 'fields' => [ |
||
26 | 'sayHi' => [ |
||
27 | 'type' => Type::nonNull(Type::string()), |
||
28 | 'args' => [ |
||
29 | 'name' => [ |
||
30 | 'type' => Type::nonNull(Type::string()), |
||
31 | ], |
||
32 | ], |
||
33 | 'resolve' => static function ($value, $args) use ($promiseAdapter) { |
||
34 | return $promiseAdapter->createFulfilled(sprintf('Hi %s!', $args['name'])); |
||
35 | }, |
||
36 | ], |
||
37 | ], |
||
38 | ] |
||
39 | ), |
||
40 | ] |
||
41 | ); |
||
42 | |||
43 | $promise = GraphQL::promiseToExecute($promiseAdapter, $schema, '{ sayHi(name: "John") }'); |
||
44 | $result = $promiseAdapter->wait($promise); |
||
45 | self::assertSame(['data' => ['sayHi' => 'Hi John!']], $result->toArray()); |
||
46 | } |
||
48 |