GraphQL\Tests\Language\VisitorTest::testAllowsForEditingOnEnter2 PHP Method

testAllowsForEditingOnEnter2() public method

    public function testAllowsForEditingOnEnter2()
    {
        $visited = [];
        $ast = Parser::parse('{ a, b, c { a, b, c } }', ['noLocation' => true]);
        $editedAst = Visitor::visit($ast, Visitor::visitInParallel([['enter' => function ($node) use(&$visited) {
            if ($node->kind === 'Field' && isset($node->name->value) && $node->name->value === 'b') {
                return Visitor::removeNode();
            }
        }], ['enter' => function ($node) use(&$visited) {
            $visited[] = ['enter', $node->kind, isset($node->value) ? $node->value : null];
        }, 'leave' => function ($node) use(&$visited) {
            $visited[] = ['leave', $node->kind, isset($node->value) ? $node->value : null];
        }]]));
        $this->assertEquals(Parser::parse('{ a, b, c { a, b, c } }', ['noLocation' => true]), $ast);
        $this->assertEquals(Parser::parse('{ a,    c { a,    c } }', ['noLocation' => true]), $editedAst);
        $this->assertEquals([['enter', 'Document', null], ['enter', 'OperationDefinition', null], ['enter', 'SelectionSet', null], ['enter', 'Field', null], ['enter', 'Name', 'a'], ['leave', 'Name', 'a'], ['leave', 'Field', null], ['enter', 'Field', null], ['enter', 'Name', 'c'], ['leave', 'Name', 'c'], ['enter', 'SelectionSet', null], ['enter', 'Field', null], ['enter', 'Name', 'a'], ['leave', 'Name', 'a'], ['leave', 'Field', null], ['enter', 'Field', null], ['enter', 'Name', 'c'], ['leave', 'Name', 'c'], ['leave', 'Field', null], ['leave', 'SelectionSet', null], ['leave', 'Field', null], ['leave', 'SelectionSet', null], ['leave', 'OperationDefinition', null], ['leave', 'Document', null]], $visited);
    }