GraphQL\Tests\Language\ParserTest::testParseCreatesAst PHP Method

testParseCreatesAst() public method

public testParseCreatesAst ( )
    public function testParseCreatesAst()
    {
        $source = new Source('{
  node(id: 4) {
    id,
    name
  }
}
');
        $result = Parser::parse($source);
        $loc = function ($start, $end) use($source) {
            return ['start' => $start, 'end' => $end];
        };
        $expected = ['kind' => NodeKind::DOCUMENT, 'loc' => $loc(0, 41), 'definitions' => [['kind' => NodeKind::OPERATION_DEFINITION, 'loc' => $loc(0, 40), 'operation' => 'query', 'name' => null, 'variableDefinitions' => null, 'directives' => [], 'selectionSet' => ['kind' => NodeKind::SELECTION_SET, 'loc' => $loc(0, 40), 'selections' => [['kind' => NodeKind::FIELD, 'loc' => $loc(4, 38), 'alias' => null, 'name' => ['kind' => NodeKind::NAME, 'loc' => $loc(4, 8), 'value' => 'node'], 'arguments' => [['kind' => NodeKind::ARGUMENT, 'name' => ['kind' => NodeKind::NAME, 'loc' => $loc(9, 11), 'value' => 'id'], 'value' => ['kind' => NodeKind::INT, 'loc' => $loc(13, 14), 'value' => '4'], 'loc' => $loc(9, 14, $source)]], 'directives' => [], 'selectionSet' => ['kind' => NodeKind::SELECTION_SET, 'loc' => $loc(16, 38), 'selections' => [['kind' => NodeKind::FIELD, 'loc' => $loc(22, 24), 'alias' => null, 'name' => ['kind' => NodeKind::NAME, 'loc' => $loc(22, 24), 'value' => 'id'], 'arguments' => [], 'directives' => [], 'selectionSet' => null], ['kind' => NodeKind::FIELD, 'loc' => $loc(30, 34), 'alias' => null, 'name' => ['kind' => NodeKind::NAME, 'loc' => $loc(30, 34), 'value' => 'name'], 'arguments' => [], 'directives' => [], 'selectionSet' => null]]]]]]]]];
        $this->assertEquals($expected, $this->nodeToArray($result));
    }