GraphQL\Tests\Executor\ExecutorTest::testSubstitutesArgumentWithDefaultValue PHP Method

testSubstitutesArgumentWithDefaultValue() public method

    public function testSubstitutesArgumentWithDefaultValue()
    {
        $schema = new Schema(['query' => new ObjectType(['name' => 'Type', 'fields' => ['field' => ['type' => Type::string(), 'resolve' => function ($data, $args) {
            return $args ? json_encode($args) : '';
        }, 'args' => ['a' => ['type' => Type::boolean(), 'defaultValue' => 1], 'b' => ['type' => Type::boolean(), 'defaultValue' => null], 'c' => ['type' => Type::boolean(), 'defaultValue' => 0], 'd' => ['type' => Type::int(), 'defaultValue' => false], 'e' => ['type' => Type::int(), 'defaultValue' => '0'], 'f' => ['type' => Type::int(), 'defaultValue' => 'some-string'], 'g' => ['type' => Type::boolean()], 'h' => ['type' => new InputObjectType(['name' => 'ComplexType', 'fields' => ['a' => ['type' => Type::int()], 'b' => ['type' => Type::string()]]]), 'defaultValue' => ['a' => 1, 'b' => 'test']]]]]])]);
        $query = Parser::parse('{ field }');
        $result = Executor::execute($schema, $query);
        $expected = ['data' => ['field' => '{"a":1,"b":null,"c":0,"d":false,"e":"0","f":"some-string","h":{"a":1,"b":"test"}}']];
        $this->assertEquals($expected, $result->toArray());
    }