From ccb9486d2191b4e7b61bd115ba279cdd3de64cf4 Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Wed, 8 Aug 2018 01:18:59 +0700 Subject: [PATCH] SchemaParser: additional test case --- tests/Language/SchemaParserTest.php | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Language/SchemaParserTest.php b/tests/Language/SchemaParserTest.php index dae4994..d34c345 100644 --- a/tests/Language/SchemaParserTest.php +++ b/tests/Language/SchemaParserTest.php @@ -200,6 +200,42 @@ extend type Hello { $this->assertEquals($expected, TestUtils::nodeToArray($doc)); } + /** + * @it Extension without fields followed by extension + */ + public function testExtensionWithoutFieldsFollowedByExtension() + { + $body = ' + extend type Hello implements Greeting + + extend type Hello implements SecondGreeting + '; + $doc = Parser::parse($body); + $expected = [ + 'kind' => 'Document', + 'definitions' => [ + [ + 'kind' => 'ObjectTypeExtension', + 'name' => $this->nameNode('Hello', ['start' => 23, 'end' => 28]), + 'interfaces' => [$this->typeNode('Greeting', ['start' => 40, 'end' => 48])], + 'directives' => [], + 'fields' => [], + 'loc' => ['start' => 11, 'end' => 48], + ], + [ + 'kind' => 'ObjectTypeExtension', + 'name' => $this->nameNode('Hello', ['start' => 76, 'end' => 81]), + 'interfaces' => [$this->typeNode('SecondGreeting', ['start' => 93, 'end' => 107])], + 'directives' => [], + 'fields' => [], + 'loc' => ['start' => 64, 'end' => 107], + ], + ], + 'loc' => ['start' => 0, 'end' => 116], + ]; + $this->assertEquals($expected, $doc->toArray(true)); + } + /** * @it Extension without anything throws */