Skip to content

Commit

Permalink
Fix tests for GeometryEngine::boundary()
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jun 5, 2024
1 parent f89b437 commit 7309d4e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/GeometryEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ public static function providerPointOnSurface() : array

/**
* @param string $geometry The WKT of the geometry to test.
* @param string $boundary The WKT of the expected boundary.
* @param string|string[] $boundary The WKT of the expected boundary. If multiple possible results, an array.
*/
#[DataProvider('providerBoundary')]
public function testBoundary(string $geometry, string $boundary) : void
public function testBoundary(string $geometry, string|array $boundary) : void
{
$geometryEngine = $this->getGeometryEngine();

Expand All @@ -344,16 +344,22 @@ public function testBoundary(string $geometry, string $boundary) : void
$this->expectException(GeometryEngineException::class);
}

self::assertSame($boundary, $geometryEngine->boundary($geometry)->asText());
$actualBoundary = $geometryEngine->boundary($geometry);

if (is_array($boundary)) {
self::assertContains($actualBoundary->asText(), $boundary);
} else {
self::assertSame($boundary, $actualBoundary->asText());
}
}

public static function providerBoundary() : array
{
return [
['POINT (1 2)', 'GEOMETRYCOLLECTION EMPTY'],
['POINT Z (2 3 4)', 'GEOMETRYCOLLECTION EMPTY'],
['POINT M (3 4 5)', 'GEOMETRYCOLLECTION EMPTY'],
['POINT ZM (4 5 6 7)', 'GEOMETRYCOLLECTION EMPTY'],
['POINT (1 2)', ['POINT EMPTY', 'GEOMETRYCOLLECTION EMPTY']],
['POINT Z (2 3 4)', ['POINT Z EMPTY', 'GEOMETRYCOLLECTION EMPTY']],
['POINT M (3 4 5)', ['POINT M EMPTY', 'GEOMETRYCOLLECTION EMPTY']],
['POINT ZM (4 5 6 7)', ['POINT ZM EMPTY', 'GEOMETRYCOLLECTION EMPTY']],
['LINESTRING (1 1, 0 0, -1 1)', 'MULTIPOINT (1 1, -1 1)'],
['POLYGON ((1 1, 0 0, -1 1, 1 1))', 'LINESTRING (1 1, 0 0, -1 1, 1 1)'],
];
Expand Down

0 comments on commit 7309d4e

Please sign in to comment.