Add test for default enum input coercion

This commit is contained in:
spawnia 2019-03-28 11:26:30 +01:00
parent 1acddf4e22
commit ddebd9a414

View File

@ -11,6 +11,7 @@ use GraphQL\Executor\Executor;
use GraphQL\Language\Parser; use GraphQL\Language\Parser;
use GraphQL\Tests\Executor\TestClasses\NotSpecial; use GraphQL\Tests\Executor\TestClasses\NotSpecial;
use GraphQL\Tests\Executor\TestClasses\Special; use GraphQL\Tests\Executor\TestClasses\Special;
use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\InputObjectType; use GraphQL\Type\Definition\InputObjectType;
use GraphQL\Type\Definition\InterfaceType; use GraphQL\Type\Definition\InterfaceType;
use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\ObjectType;
@ -1108,6 +1109,16 @@ class ExecutorTest extends TestCase
], ],
]), 'defaultValue' => ['a' => 1, 'b' => 'test'], ]), 'defaultValue' => ['a' => 1, 'b' => 'test'],
], ],
'i' => [
'type' => new EnumType([
'name' => 'EnumType',
'values' => [
'VALUE1' => 1,
'VALUE2' => 2,
]
]),
'defaultValue' => 1
]
], ],
], ],
], ],
@ -1117,7 +1128,7 @@ class ExecutorTest extends TestCase
$query = Parser::parse('{ field }'); $query = Parser::parse('{ field }');
$result = Executor::execute($schema, $query); $result = Executor::execute($schema, $query);
$expected = [ $expected = [
'data' => ['field' => '{"a":1,"b":null,"c":0,"d":false,"e":"0","f":"some-string","h":{"a":1,"b":"test"}}'], 'data' => ['field' => '{"a":1,"b":null,"c":0,"d":false,"e":"0","f":"some-string","h":{"a":1,"b":"test"},"i":1}'],
]; ];
self::assertEquals($expected, $result->toArray()); self::assertEquals($expected, $result->toArray());