GraphQL\Tests\Executor\VariablesTest::testDoesNotAllowNonNullableInputsToBeSetToNullInAVariable PHP Method

testDoesNotAllowNonNullableInputsToBeSetToNullInAVariable() public method

    public function testDoesNotAllowNonNullableInputsToBeSetToNullInAVariable()
    {
        $doc = '
        query SetsNonNullable($value: String!) {
          fieldWithNonNullableStringInput(input: $value)
        }
        ';
        $ast = Parser::parse($doc);
        try {
            Executor::execute($this->schema(), $ast, null, null, ['value' => null]);
            $this->fail('Expected exception not thrown');
        } catch (Error $e) {
            $expected = ['message' => 'Variable "$value" got invalid value null.' . "\n" . 'Expected "String!", found null.', 'locations' => [['line' => 2, 'column' => 31]]];
            $this->assertEquals($expected, Error::formatError($e));
        }
    }