From ddebd9a414d58c5ed105328309bab3a1cb09743c Mon Sep 17 00:00:00 2001 From: spawnia Date: Thu, 28 Mar 2019 11:26:30 +0100 Subject: [PATCH] Add test for default enum input coercion --- tests/Executor/ExecutorTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/Executor/ExecutorTest.php b/tests/Executor/ExecutorTest.php index fe6768c..d3679e8 100644 --- a/tests/Executor/ExecutorTest.php +++ b/tests/Executor/ExecutorTest.php @@ -11,6 +11,7 @@ use GraphQL\Executor\Executor; use GraphQL\Language\Parser; use GraphQL\Tests\Executor\TestClasses\NotSpecial; use GraphQL\Tests\Executor\TestClasses\Special; +use GraphQL\Type\Definition\EnumType; use GraphQL\Type\Definition\InputObjectType; use GraphQL\Type\Definition\InterfaceType; use GraphQL\Type\Definition\ObjectType; @@ -1108,6 +1109,16 @@ class ExecutorTest extends TestCase ], ]), '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 }'); $result = Executor::execute($schema, $query); $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());