| @@ 10-32 (lines=23) @@ | ||
| 7 | class Issue109Test extends \PHPUnit_Framework_TestCase |
|
| 8 | { |
|
| 9 | ||
| 10 | public function testInternalVariableArgument() |
|
| 11 | { |
|
| 12 | $schema = new Issue109Schema(); |
|
| 13 | $processor = new Processor($schema); |
|
| 14 | $response = $processor->processPayload(' |
|
| 15 | query ($postId: Int, $commentId: Int) { |
|
| 16 | latestPost(id: $postId) { |
|
| 17 | id(comment_id: $commentId), comments(comment_id: $commentId) { |
|
| 18 | comment_id |
|
| 19 | } |
|
| 20 | } |
|
| 21 | }', |
|
| 22 | [ |
|
| 23 | 'postId' => 1, |
|
| 24 | 'commentId' => 100 |
|
| 25 | ])->getResponseData(); |
|
| 26 | $this->assertEquals(['data' => ['latestPost' => [ |
|
| 27 | 'id' => 1, |
|
| 28 | 'comments' => [ |
|
| 29 | ['comment_id' => 100] |
|
| 30 | ] |
|
| 31 | ]]], $response); |
|
| 32 | } |
|
| 33 | } |
|
| @@ 34-61 (lines=28) @@ | ||
| 31 | $this->assertEquals($validResult, $responseData); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testInvalidVariableType() |
|
| 35 | { |
|
| 36 | $processor = new Processor(new StarWarsSchema()); |
|
| 37 | ||
| 38 | $processor->processPayload( |
|
| 39 | 'query($someId: Int){ |
|
| 40 | human(id: $someId) { |
|
| 41 | name |
|
| 42 | } |
|
| 43 | }' |
|
| 44 | ); |
|
| 45 | ||
| 46 | $data = $processor->getResponseData(); |
|
| 47 | $this->assertEquals($data, [ |
|
| 48 | 'data' => ['human' => null], |
|
| 49 | 'errors' => [ |
|
| 50 | [ |
|
| 51 | 'message' => 'Invalid variable "someId" type, allowed type is "ID"', |
|
| 52 | 'locations' => [ |
|
| 53 | [ |
|
| 54 | 'line' => 1, |
|
| 55 | 'column' => 7 |
|
| 56 | ] |
|
| 57 | ] |
|
| 58 | ] |
|
| 59 | ] |
|
| 60 | ]); |
|
| 61 | } |
|
| 62 | ||
| 63 | ||
| 64 | public function dataProvider() |
|