GraphQL\Tests\Utils\ASTFromValueTest::testConvertsIntValuesToASTs PHP Метод

testConvertsIntValuesToASTs() публичный Метод

    public function testConvertsIntValuesToASTs()
    {
        $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123.0, Type::int()));
        $this->assertEquals(new IntValueNode(['value' => '123']), AST::astFromValue(123.5, Type::int()));
        $this->assertEquals(new IntValueNode(['value' => '10000']), AST::astFromValue(10000.0, Type::int()));
        try {
            AST::astFromValue(1.0E+40, Type::int());
            // Note: js version will produce 1e+40, both values are valid GraphQL floats
            $this->fail('Expected exception is not thrown');
        } catch (\Exception $e) {
            $this->assertSame('Int cannot represent non 32-bit signed integer value: 1.0E+40', $e->getMessage());
        }
    }