Jsor\Doctrine\PostGIS\Functions\ST_AsGeoJSONTest::testQuery2 PHP Method

testQuery2() public method

public testQuery2 ( )
    public function testQuery2()
    {
        $query = $this->_getEntityManager()->createQuery('SELECT ST_AsGeoJSON(1, ST_GeomFromText(\'LINESTRING(1 2 3, 4 5 6)\', 4326), 15, 2) FROM Jsor\\Doctrine\\PostGIS\\PointsEntity');
        $result = $query->getSingleResult();
        array_walk_recursive($result, function (&$data) {
            if (is_resource($data)) {
                $data = stream_get_contents($data);
                if (false !== ($pos = strpos($data, 'x'))) {
                    $data = substr($data, $pos + 1);
                }
            }
            if (is_string($data)) {
                $data = trim($data);
            }
        });
        $expected = array(1 => '{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[[1,2,3],[4,5,6]]}');
        $this->assertEquals($expected, $result, '', 0.0001);
    }