Skip to content

Commit

Permalink
Fix split test for SpatiaLite
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jun 5, 2024
1 parent 9aa124a commit 0eeda28
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tests/GeometryEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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)))',
]],
];
}

Expand Down

0 comments on commit 0eeda28

Please sign in to comment.