Skip to content

Commit c85a619

Browse files
committed
Add interface implementing interface parser test
1 parent 8ead4df commit c85a619

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

tests/Language/SchemaParserTest.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,83 @@ interface Hello {
620620
self::assertEquals($expected, TestUtils::nodeToArray($doc));
621621
}
622622

623+
/**
624+
* @see it('Simple interface inheriting interface')
625+
*/
626+
public function testSimpleInterfaceInheritingInterface() : void
627+
{
628+
$body = 'interface Hello implements World { field: String }';
629+
$doc = Parser::parse($body);
630+
$loc = static function ($start, $end) : array {
631+
return TestUtils::locArray($start, $end);
632+
};
633+
634+
$expected = [
635+
'kind' => NodeKind::DOCUMENT,
636+
'definitions' => [
637+
[
638+
'kind' => NodeKind::INTERFACE_TYPE_DEFINITION,
639+
'name' => $this->nameNode('Hello', $loc(10, 15)),
640+
'interfaces' => [
641+
$this->typeNode('World', $loc(27, 32)),
642+
],
643+
'directives' => [],
644+
'fields' => [
645+
$this->fieldNode(
646+
$this->nameNode('field', $loc(35, 40)),
647+
$this->typeNode('String', $loc(42, 48)),
648+
$loc(30, 43)
649+
),
650+
],
651+
'loc' => $loc(0, 50),
652+
'description' => null,
653+
],
654+
],
655+
'loc' => $loc(0, 50),
656+
];
657+
658+
self::assertEquals($expected, TestUtils::nodeToArray($doc));
659+
}
660+
661+
/**
662+
* @see it('Simple interface inheriting multiple interfaces')
663+
*/
664+
public function testSimpleInterfaceInheritingMultipleInterfaces() : void
665+
{
666+
$body = 'interface Hello implements Wo & rld { field: String }';
667+
$doc = Parser::parse($body);
668+
$loc = static function ($start, $end) : array {
669+
return TestUtils::locArray($start, $end);
670+
};
671+
672+
$expected = [
673+
'kind' => NodeKind::DOCUMENT,
674+
'definitions' => [
675+
[
676+
'kind' => NodeKind::INTERFACE_TYPE_DEFINITION,
677+
'name' => $this->nameNode('Hello', $loc(10, 15)),
678+
'interfaces' => [
679+
$this->typeNode('Wo', $loc(27, 29)),
680+
$this->typeNode('rld', $loc(32, 35)),
681+
],
682+
'directives' => [],
683+
'fields' => [
684+
$this->fieldNode(
685+
$this->nameNode('field', $loc(38, 43)),
686+
$this->typeNode('String', $loc(45, 51)),
687+
$loc(38, 51)
688+
),
689+
],
690+
'loc' => $loc(0, 53),
691+
'description' => null,
692+
],
693+
],
694+
'loc' => $loc(0, 53),
695+
];
696+
697+
self::assertEquals($expected, TestUtils::nodeToArray($doc));
698+
}
699+
623700
/**
624701
* @see it('Simple field with arg')
625702
*/

0 commit comments

Comments
 (0)