Passed
Push — master ( ed1746...93ccd7 )
by Vladimir
09:00
created

Issue467Test   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testInputObjectValidation() 0 28 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Tests\Regression;
6
7
use GraphQL\GraphQL;
8
use GraphQL\Utils\BuildSchema;
9
use PHPUnit\Framework\TestCase;
10
11
/**
12
 * @see https://github.com/webonyx/graphql-php/issues/467
13
 */
14
class Issue467Test extends TestCase
15
{
16
    public function testInputObjectValidation()
17
    {
18
        $schemaStr = '
19
input MsgInput {
20
  msg: String
21
}
22
23
type Query {
24
  echo(msg: MsgInput): String
25
}
26
27
schema {
28
    query: Query
29
}
30
';
31
32
        $query     = '
33
query echo ($msg: MsgInput) {
34
          echo (msg: $msg)
35
}';
36
        $variables = ['msg' => ['my message']];
37
38
        $schema = BuildSchema::build($schemaStr);
39
        $result = GraphQL::executeQuery($schema, $query, null, null, $variables);
40
41
        $expectedError = 'Variable "$msg" got invalid value ["my message"]; Field "0" is not defined by type MsgInput.';
42
        self::assertCount(1, $result->errors);
43
        self::assertEquals($expectedError, $result->errors[0]->getMessage());
44
    }
45
}
46