GraphQL\Tests\Executor\UnionInterfaceTest::testGetsExecutionInfoInResolver PHP Method

testGetsExecutionInfoInResolver() public method

    public function testGetsExecutionInfoInResolver()
    {
        $encounteredContext = null;
        $encounteredSchema = null;
        $encounteredRootValue = null;
        $PersonType2 = null;
        $NamedType2 = new InterfaceType(['name' => 'Named', 'fields' => ['name' => ['type' => Type::string()]], 'resolveType' => function ($obj, $context, ResolveInfo $info) use(&$encounteredContext, &$encounteredSchema, &$encounteredRootValue, &$PersonType2) {
            $encounteredContext = $context;
            $encounteredSchema = $info->schema;
            $encounteredRootValue = $info->rootValue;
            return $PersonType2;
        }]);
        $PersonType2 = new ObjectType(['name' => 'Person', 'interfaces' => [$NamedType2], 'fields' => ['name' => ['type' => Type::string()], 'friends' => ['type' => Type::listOf($NamedType2)]]]);
        $schema2 = new Schema(['query' => $PersonType2]);
        $john2 = new Person('John', [], [$this->liz]);
        $context = ['authToken' => '123abc'];
        $ast = Parser::parse('{ name, friends { name } }');
        $this->assertEquals(['data' => ['name' => 'John', 'friends' => [['name' => 'Liz']]]], GraphQL::execute($schema2, $ast, $john2, $context));
        $this->assertSame($context, $encounteredContext);
        $this->assertSame($schema2, $encounteredSchema);
        $this->assertSame($john2, $encounteredRootValue);
    }