Skip to content

Commit 032bfbf

Browse files
Generate functions
1 parent 8f1cc71 commit 032bfbf

17 files changed

+344
-0
lines changed

tests/Functions/ST_3DClosestPointTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{

tests/Functions/ST_3DShortestLineTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{

tests/Functions/ST_BoundaryTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ protected function setUp(): void
4848
$em->clear();
4949
}
5050

51+
/**
52+
* @group postgis-3.0
53+
* @group postgis-3.1
54+
* @group postgis-3.2
55+
* @group versioned
56+
*/
5157
public function testQuery1(): void
5258
{
5359
$query = $this->_getEntityManager()->createQuery('SELECT ST_AsText(ST_Boundary(ST_GeomFromText(\'LINESTRING(1 1,0 0, -1 1)\'))) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
@@ -74,4 +80,36 @@ public function testQuery1(): void
7480

7581
$this->assertEqualsWithDelta($expected, $result, 0.001);
7682
}
83+
84+
/**
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
88+
*/
89+
public function testQuery2(): void
90+
{
91+
$query = $this->_getEntityManager()->createQuery('SELECT ST_AsText(ST_Boundary(ST_GeomFromText(\'LINESTRING(1 1,0 0, -1 1)\'))) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
92+
93+
$result = $query->getSingleResult();
94+
95+
array_walk_recursive($result, static function (&$data): void {
96+
if (is_resource($data)) {
97+
$data = stream_get_contents($data);
98+
99+
if (false !== ($pos = strpos($data, 'x'))) {
100+
$data = substr($data, $pos + 1);
101+
}
102+
}
103+
104+
if (is_string($data)) {
105+
$data = trim($data);
106+
}
107+
});
108+
109+
$expected = [
110+
'value' => 'MULTIPOINT((1 1),(-1 1))',
111+
];
112+
113+
$this->assertEqualsWithDelta($expected, $result, 0.001);
114+
}
77115
}

tests/Functions/ST_Box2dFromGeoHashTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{
@@ -137,6 +142,7 @@ public function testQuery3(): void
137142

138143
/**
139144
* @group postgis-3.0
145+
* @group versioned
140146
*/
141147
public function testQuery4(): void
142148
{
@@ -167,6 +173,10 @@ public function testQuery4(): void
167173

168174
/**
169175
* @group postgis-3.1
176+
* @group postgis-3.2
177+
* @group postgis-3.3
178+
* @group postgis-3.4
179+
* @group versioned
170180
*/
171181
public function testQuery5(): void
172182
{

tests/Functions/ST_BufferTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,7 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group versioned
8385
*/
8486
public function testQuery2(): void
8587
{
@@ -108,7 +110,40 @@ public function testQuery2(): void
108110
$this->assertEqualsWithDelta($expected, $result, 0.001);
109111
}
110112

113+
/**
114+
* @group postgis-3.2
115+
* @group postgis-3.3
116+
* @group postgis-3.4
117+
* @group versioned
118+
*/
111119
public function testQuery3(): void
120+
{
121+
$query = $this->_getEntityManager()->createQuery('SELECT ST_AsText(ST_Buffer(ST_GeomFromText(\'POINT(100 90)\'), 50, \'quad_segs=8\')) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
122+
123+
$result = $query->getSingleResult();
124+
125+
array_walk_recursive($result, static function (&$data): void {
126+
if (is_resource($data)) {
127+
$data = stream_get_contents($data);
128+
129+
if (false !== ($pos = strpos($data, 'x'))) {
130+
$data = substr($data, $pos + 1);
131+
}
132+
}
133+
134+
if (is_string($data)) {
135+
$data = trim($data);
136+
}
137+
});
138+
139+
$expected = [
140+
'value' => 'POLYGON((150 90,149.0392640201615 80.24548389919359,146.19397662556435 70.86582838174552,141.57348061512727 62.22148834901989,135.35533905932738 54.64466094067263,127.77851165098011 48.42651938487274,119.1341716182545 43.80602337443566,109.75451610080641 40.960735979838475,100 40,90.24548389919359 40.960735979838475,80.86582838174552 43.80602337443566,72.2214883490199 48.426519384872734,64.64466094067262 54.64466094067262,58.426519384872734 62.22148834901989,53.80602337443566 70.8658283817455,50.960735979838475 80.24548389919357,50 90,50.960735979838475 99.75451610080641,53.80602337443566 109.13417161825448,58.42651938487273 117.7785116509801,64.64466094067262 125.35533905932738,72.22148834901989 131.57348061512727,80.86582838174549 136.19397662556432,90.24548389919357 139.0392640201615,99.99999999999999 140,109.75451610080641 139.0392640201615,119.1341716182545 136.19397662556435,127.7785116509801 131.57348061512727,135.35533905932738 125.35533905932738,141.57348061512727 117.77851165098011,146.19397662556432 109.13417161825453,149.0392640201615 99.75451610080644,150 90))',
141+
];
142+
143+
$this->assertEqualsWithDelta($expected, $result, 0.001);
144+
}
145+
146+
public function testQuery4(): void
112147
{
113148
$query = $this->_getEntityManager()->createQuery('SELECT ST_NPoints(ST_Buffer(ST_GeomFromText(\'POINT(100 90)\'), 50)) AS promisingcircle_pcount, ST_NPoints(ST_Buffer(ST_GeomFromText(\'POINT(100 90)\'), 50, 2)) AS lamecircle_pcount FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
114149

tests/Functions/ST_CentroidTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{

tests/Functions/ST_CollectTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ protected function setUp(): void
4848
$em->clear();
4949
}
5050

51+
/**
52+
* @group postgis-3.0
53+
* @group postgis-3.1
54+
* @group postgis-3.2
55+
* @group versioned
56+
*/
5157
public function testQuery1(): void
5258
{
5359
$query = $this->_getEntityManager()->createQuery('SELECT ST_AsText(ST_Collect(ST_GeomFromText(\'POINT(1 2)\'), ST_GeomFromText(\'POINT(-2 3)\') )) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
@@ -74,4 +80,36 @@ public function testQuery1(): void
7480

7581
$this->assertEqualsWithDelta($expected, $result, 0.001);
7682
}
83+
84+
/**
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
88+
*/
89+
public function testQuery2(): void
90+
{
91+
$query = $this->_getEntityManager()->createQuery('SELECT ST_AsText(ST_Collect(ST_GeomFromText(\'POINT(1 2)\'), ST_GeomFromText(\'POINT(-2 3)\') )) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
92+
93+
$result = $query->getSingleResult();
94+
95+
array_walk_recursive($result, static function (&$data): void {
96+
if (is_resource($data)) {
97+
$data = stream_get_contents($data);
98+
99+
if (false !== ($pos = strpos($data, 'x'))) {
100+
$data = substr($data, $pos + 1);
101+
}
102+
}
103+
104+
if (is_string($data)) {
105+
$data = trim($data);
106+
}
107+
});
108+
109+
$expected = [
110+
'value' => 'MULTIPOINT((1 2),(-2 3))',
111+
];
112+
113+
$this->assertEqualsWithDelta($expected, $result, 0.001);
114+
}
77115
}

tests/Functions/ST_GeomFromGeoHashTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{

tests/Functions/ST_LineCrossingDirectionTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ protected function setUp(): void
4747
$em->clear();
4848
}
4949

50+
/**
51+
* @group postgis-3.0
52+
* @group postgis-3.1
53+
* @group postgis-3.2
54+
* @group versioned
55+
*/
5056
public function testQuery1(): void
5157
{
5258
$query = $this->_getEntityManager()->createQuery('SELECT ST_LineCrossingDirection(ST_GeomFromText(\'LINESTRING(25 169,89 114,40 70,86 43)\'), ST_GeomFromText(\'LINESTRING(171 154,20 140,71 74,161 53)\')) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
@@ -71,4 +77,34 @@ public function testQuery1(): void
7177

7278
$this->assertEqualsWithDelta($expected, $result, 0.001);
7379
}
80+
81+
/**
82+
* @group postgis-3.3
83+
* @group postgis-3.4
84+
* @group versioned
85+
*/
86+
public function testQuery2(): void
87+
{
88+
$query = $this->_getEntityManager()->createQuery('SELECT ST_LineCrossingDirection(ST_GeomFromText(\'LINESTRING(25 169,89 114,40 70,86 43)\'), ST_GeomFromText(\'LINESTRING(171 154,20 140,71 74,161 53)\')) AS value FROM Jsor\\Doctrine\\PostGIS\\Entity\\PointsEntity point');
89+
90+
$result = $query->getSingleResult();
91+
92+
array_walk_recursive($result, static function (&$data): void {
93+
if (is_resource($data)) {
94+
$data = stream_get_contents($data);
95+
96+
if (false !== ($pos = strpos($data, 'x'))) {
97+
$data = substr($data, $pos + 1);
98+
}
99+
}
100+
101+
$data = (float) $data;
102+
});
103+
104+
$expected = [
105+
'value' => 3.0,
106+
];
107+
108+
$this->assertEqualsWithDelta($expected, $result, 0.001);
109+
}
74110
}

tests/Functions/ST_MinimumBoundingCircleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050

5151
/**
5252
* @group postgis-3.0
53+
* @group versioned
5354
*/
5455
public function testQuery1(): void
5556
{
@@ -80,6 +81,10 @@ public function testQuery1(): void
8081

8182
/**
8283
* @group postgis-3.1
84+
* @group postgis-3.2
85+
* @group postgis-3.3
86+
* @group postgis-3.4
87+
* @group versioned
8388
*/
8489
public function testQuery2(): void
8590
{

0 commit comments

Comments
 (0)