From 0eeda280f7a06b332bde9230aaac1c80d0169ba0 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Wed, 5 Jun 2024 22:02:02 +0200 Subject: [PATCH] Fix split test for SpatiaLite --- tests/GeometryEngineTest.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/GeometryEngineTest.php b/tests/GeometryEngineTest.php index 93e6222..af2a8d5 100644 --- a/tests/GeometryEngineTest.php +++ b/tests/GeometryEngineTest.php @@ -1162,8 +1162,11 @@ public static function providerTransform() : array ]; } + /** + * @param string|string[] $expectedWKT + */ #[DataProvider('providerSplit')] - public function testSplit(string $originalWKT, string $bladeWKT, string $expectedWKT) : void + public function testSplit(string $originalWKT, string $bladeWKT, string|array $expectedWKT) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1176,16 +1179,32 @@ public function testSplit(string $originalWKT, string $bladeWKT, string $expecte $splitGeometry = $geometryEngine->split($originalGeometry, $bladeGeometry); - $this->assertSame($expectedWKT, $splitGeometry->asText()); + if (is_array($expectedWKT)) { + self::assertContains($splitGeometry->asText(), $expectedWKT); + } else { + $this->assertSame($expectedWKT, $splitGeometry->asText()); + } } public static function providerSplit() : array { return [ - ['LINESTRING (1 1, 3 3)', 'POINT (2 2)', 'GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), LINESTRING (2 2, 3 3))'], - ['LINESTRING (1 1, 1 2, 2 2, 2 1, 1 1)', 'LINESTRING (0 0, 3 3)', 'GEOMETRYCOLLECTION (LINESTRING (1 1, 1 2, 2 2), LINESTRING (2 2, 2 1, 1 1))'], - ['POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1))', 'LINESTRING (0 0, 3 3)', 'GEOMETRYCOLLECTION (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((2 2, 2 1, 1 1, 2 2)))'], - ['POLYGON ((1 1, 1 2, 3 2, 3 1, 1 1))', 'LINESTRING (1 1, 2 2, 3 1)', 'GEOMETRYCOLLECTION (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((1 1, 2 2, 3 1, 1 1)), POLYGON ((3 1, 2 2, 3 2, 3 1)))'], + ['LINESTRING (1 1, 3 3)', 'POINT (2 2)', [ + 'MULTILINESTRING (LINESTRING (1 1, 2 2), LINESTRING (2 2, 3 3))', + 'GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), LINESTRING (2 2, 3 3))', + ]], + ['LINESTRING (1 1, 1 2, 2 2, 2 1, 1 1)', 'LINESTRING (0 0, 3 3)', [ + 'MULTILINESTRING (LINESTRING (1 1, 1 2, 2 2), LINESTRING (2 2, 2 1, 1 1))', + 'GEOMETRYCOLLECTION (LINESTRING (1 1, 1 2, 2 2), LINESTRING (2 2, 2 1, 1 1))', + ]], + ['POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1))', 'LINESTRING (0 0, 3 3)', [ + 'MULTIPOLYGON (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((2 2, 2 1, 1 1, 2 2)))', + 'GEOMETRYCOLLECTION (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((2 2, 2 1, 1 1, 2 2)))', + ]], + ['POLYGON ((1 1, 1 2, 3 2, 3 1, 1 1))', 'LINESTRING (1 1, 2 2, 3 1)', [ + 'MULTIPOLYGON (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((1 1, 2 2, 3 1, 1 1)), POLYGON ((3 1, 2 2, 3 2, 3 1)))', + 'GEOMETRYCOLLECTION (POLYGON ((1 1, 1 2, 2 2, 1 1)), POLYGON ((1 1, 2 2, 3 1, 1 1)), POLYGON ((3 1, 2 2, 3 2, 3 1)))', + ]], ]; }