diff --git a/tests/CircularStringTest.php b/tests/CircularStringTest.php index a76f5d1..848e69e 100644 --- a/tests/CircularStringTest.php +++ b/tests/CircularStringTest.php @@ -10,6 +10,7 @@ use Brick\Geo\Exception\InvalidGeometryException; use Brick\Geo\Exception\NoSuchGeometryException; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class CircularString. @@ -17,13 +18,12 @@ class CircularStringTest extends AbstractTestCase { /** - * @dataProvider providerCreate - * * @param string[] $pointsWKT The WKT of the Points that compose the CircularString. * @param bool $is3D Whether the points have Z coordinates. * @param bool $isMeasured Whether the points have M coordinates. * @param string $circularStringWKT The WKT of the expected CircularString. */ + #[DataProvider('providerCreate')] public function testCreate(array $pointsWKT, bool $is3D, bool $isMeasured, string $circularStringWKT) : void { foreach ([0, 1] as $srid) { @@ -46,10 +46,9 @@ public static function providerCreate() : array } /** - * @dataProvider providerCreateInvalidCircularString - * * @param string $circularString The WKT of an invalid CircularString. */ + #[DataProvider('providerCreateInvalidCircularString')] public function testCreateInvalidCircularString(string $circularString) : void { $this->expectException(InvalidGeometryException::class); @@ -66,9 +65,7 @@ public static function providerCreateInvalidCircularString() : array ]; } - /** - * @dataProvider providerStartPointEndPoint - */ + #[DataProvider('providerStartPointEndPoint')] public function testStartPointEndPoint(string $circularString, string $startPoint, string $endPoint) : void { foreach ([0, 1] as $srid) { @@ -89,10 +86,9 @@ public static function providerStartPointEndPoint() : array } /** - * @dataProvider providerEmptyCircularString - * * @param string $circularString The WKT of an empty CircularString. */ + #[DataProvider('providerEmptyCircularString')] public function testStartPointOfEmptyCircularString(string $circularString) : void { $this->expectException(EmptyGeometryException::class); @@ -100,10 +96,9 @@ public function testStartPointOfEmptyCircularString(string $circularString) : vo } /** - * @dataProvider providerEmptyCircularString - * * @param string $circularString The WKT of an empty CircularString. */ + #[DataProvider('providerEmptyCircularString')] public function testEndPointOfEmptyCircularString(string $circularString) : void { $this->expectException(EmptyGeometryException::class); @@ -120,9 +115,7 @@ public static function providerEmptyCircularString() : array ]; } - /** - * @dataProvider providerNumPoints - */ + #[DataProvider('providerNumPoints')] public function testNumPoints(string $circularString, int $numPoints) : void { $circularString = CircularString::fromText($circularString); @@ -143,9 +136,7 @@ public static function providerNumPoints() : array ]; } - /** - * @dataProvider providerPointN - */ + #[DataProvider('providerPointN')] public function testPointN(string $lineString, int $n, string $pointN) : void { foreach ([0, 1] as $srid) { @@ -172,9 +163,7 @@ public static function providerPointN() : array ]; } - /** - * @dataProvider providerInvalidPointNThrowsException - */ + #[DataProvider('providerInvalidPointNThrowsException')] public function testInvalidPointNThrowsException(string $lineString, int $n) : void { $this->expectException(NoSuchGeometryException::class); diff --git a/tests/CompoundCurveTest.php b/tests/CompoundCurveTest.php index eb4f9a2..819b1bf 100644 --- a/tests/CompoundCurveTest.php +++ b/tests/CompoundCurveTest.php @@ -10,6 +10,7 @@ use Brick\Geo\Exception\EmptyGeometryException; use Brick\Geo\Exception\InvalidGeometryException; use Brick\Geo\Exception\NoSuchGeometryException; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class CompoundCurve. @@ -17,13 +18,12 @@ class CompoundCurveTest extends AbstractTestCase { /** - * @dataProvider providerCreate - * * @param string[] $curvesWKT The WKT of the Curves that compose the CompoundCurve. * @param bool $is3D Whether the curves have Z coordinates. * @param bool $isMeasured Whether the curves have M coordinates. * @param string $compoundCurveWKT The WKT of the expected CompoundCurve. */ + #[DataProvider('providerCreate')] public function testCreate(array $curvesWKT, bool $is3D, bool $isMeasured, string $compoundCurveWKT) : void { foreach ([0, 1] as $srid) { @@ -46,10 +46,9 @@ public static function providerCreate() : array } /** - * @dataProvider providerCreateInvalidCompoundCurve - * * @param string $compoundCurve The WKT of an invalid CompoundCurve. */ + #[DataProvider('providerCreateInvalidCompoundCurve')] public function testCreateInvalidCompoundCurve(string $compoundCurve) : void { $this->expectException(InvalidGeometryException::class); @@ -65,9 +64,7 @@ public static function providerCreateInvalidCompoundCurve() : array ]; } - /** - * @dataProvider providerStartPointEndPoint - */ + #[DataProvider('providerStartPointEndPoint')] public function testStartPointEndPoint(string $compoundCurve, string $startPoint, string $endPoint) : void { foreach ([0, 1] as $srid) { @@ -88,10 +85,9 @@ public static function providerStartPointEndPoint() : array } /** - * @dataProvider providerEmptyCompoundCurve - * * @param string $compoundCurve The WKT of an empty CompoundCurve. */ + #[DataProvider('providerEmptyCompoundCurve')] public function testStartPointOfEmptyCompoundCurve(string $compoundCurve) : void { $this->expectException(EmptyGeometryException::class); @@ -99,10 +95,9 @@ public function testStartPointOfEmptyCompoundCurve(string $compoundCurve) : void } /** - * @dataProvider providerEmptyCompoundCurve - * * @param string $compoundCurve The WKT of an empty CompoundCurve. */ + #[DataProvider('providerEmptyCompoundCurve')] public function testEndPointOfEmptyCompoundCurve(string $compoundCurve) : void { $this->expectException(EmptyGeometryException::class); @@ -120,11 +115,10 @@ public static function providerEmptyCompoundCurve() : array } /** - * @dataProvider providerNumCurves - * * @param string $compoundCurve The WKT of the CompoundCurve to test. * @param int $numCurves The expected number of curves. */ + #[DataProvider('providerNumCurves')] public function testNumCurves(string $compoundCurve, int $numCurves) : void { self::assertSame($numCurves, CompoundCurve::fromText($compoundCurve)->numCurves()); @@ -145,13 +139,12 @@ public static function providerNumCurves() : array } /** - * @dataProvider providerCurveN - * * @param string $compoundCurve The WKT of the CompoundCurve to test. * @param int $n The curve number. * @param string|null $curveN The WKT of the expected curve, or NULL if an exception is expected. * @param int $srid The SRID of the geometries. */ + #[DataProvider('providerCurveN')] public function testCurveN(string $compoundCurve, int $n, ?string $curveN, int $srid) : void { if ($curveN === null) { diff --git a/tests/CurvePolygonTest.php b/tests/CurvePolygonTest.php index ead2a4f..74ef59a 100644 --- a/tests/CurvePolygonTest.php +++ b/tests/CurvePolygonTest.php @@ -8,15 +8,14 @@ use Brick\Geo\CurvePolygon; use Brick\Geo\Exception\EmptyGeometryException; use Brick\Geo\Exception\NoSuchGeometryException; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class CurvePolygon. */ class CurvePolygonTest extends AbstractTestCase { - /** - * @dataProvider providerEmptyFactoryMethod - */ + #[DataProvider('providerEmptyFactoryMethod')] public function testEmptyFactoryMethod(bool $is3D, bool $isMeasured, int $srid) : void { $cs = new CoordinateSystem($is3D, $isMeasured, $srid); @@ -43,11 +42,10 @@ public static function providerEmptyFactoryMethod() : array } /** - * @dataProvider providerExteriorRing - * * @param string $curvePolygon The WKT of the CurvePolygon to test. * @param string $exteriorRing The WKT of the expected exterior ring. */ + #[DataProvider('providerExteriorRing')] public function testExteriorRing(string $curvePolygon, string $exteriorRing) : void { foreach ([0, 1] as $srid) { @@ -67,10 +65,9 @@ public static function providerExteriorRing() : array } /** - * @dataProvider providerExteriorRingOfEmptyCurvePolygon - * * @param string $polygon The WKT of the CurvePolygon to test. */ + #[DataProvider('providerExteriorRingOfEmptyCurvePolygon')] public function testExteriorRingOfEmptyCurvePolygon(string $polygon) : void { $this->expectException(EmptyGeometryException::class); @@ -87,11 +84,10 @@ public static function providerExteriorRingOfEmptyCurvePolygon() : array ]; } /** - * @dataProvider providerNumInteriorRings - * * @param string $polygon The WKT of the Polygon to test. * @param int $numInteriorRings The expected number of interior rings. */ + #[DataProvider('providerNumInteriorRings')] public function testNumInteriorRings(string $polygon, int $numInteriorRings) : void { $polygon = CurvePolygon::fromText($polygon); @@ -114,13 +110,12 @@ public static function providerNumInteriorRings() : array } /** - * @dataProvider providerInteriorRingN - * * @param string $curvePolygon The WKT of the CurvePolygon to test. * @param int $n The ring number. * @param string|null $interiorRingN The WKT of the expected interior ring, or NULL if an exception is expected. * @param int $srid The SRID of the geometries. */ + #[DataProvider('providerInteriorRingN')] public function testInteriorRingN(string $curvePolygon, int $n, ?string $interiorRingN, int $srid) : void { if ($interiorRingN === null) { diff --git a/tests/CurveTest.php b/tests/CurveTest.php index 98676d7..a262f2a 100644 --- a/tests/CurveTest.php +++ b/tests/CurveTest.php @@ -6,6 +6,7 @@ use Brick\Geo\Curve; use Brick\Geo\Exception\EmptyGeometryException; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class Curve. @@ -13,12 +14,11 @@ class CurveTest extends AbstractTestCase { /** - * @dataProvider providerStartPointEndPoint - * * @param string $lineString The WKT of the Curve to test. * @param string $startPoint The WKT of the expected start point. * @param string $endPoint The WKT of the expected end point. */ + #[DataProvider('providerStartPointEndPoint')] public function testStartPointEndPoint(string $lineString, string $startPoint, string $endPoint) : void { foreach ([0, 1] as $srid) { @@ -49,18 +49,14 @@ public static function providerStartPointEndPoint() : array ]; } - /** - * @dataProvider providerEmptyCurve - */ + #[DataProvider('providerEmptyCurve')] public function testStartPointOfEmptyCurveThrowsException(string $lineString) : void { $this->expectException(EmptyGeometryException::class); Curve::fromText($lineString)->startPoint(); } - /** - * @dataProvider providerEmptyCurve - */ + #[DataProvider('providerEmptyCurve')] public function testEndPointOfEmptyCurveThrowsException(string $lineString) : void { $this->expectException(EmptyGeometryException::class); diff --git a/tests/GeometryCollectionTest.php b/tests/GeometryCollectionTest.php index 4cec457..3794223 100644 --- a/tests/GeometryCollectionTest.php +++ b/tests/GeometryCollectionTest.php @@ -8,6 +8,7 @@ use Brick\Geo\GeometryCollection; use Brick\Geo\LineString; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class GeometryCollection. @@ -15,11 +16,10 @@ class GeometryCollectionTest extends AbstractTestCase { /** - * @dataProvider providerNumGeometries - * * @param string $geometry The WKT of the GeometryCollection to test. * @param int $numGeometries The expected number of geometries. */ + #[DataProvider('providerNumGeometries')] public function testNumGeometries(string $geometry, int $numGeometries) : void { $geometry = GeometryCollection::fromText($geometry); @@ -36,13 +36,12 @@ public static function providerNumGeometries() : array } /** - * @dataProvider providerGeometryN - * * @param string $geometry The WKT of the GeometryCollection to test. * @param int $n The number of the geometry to return. * @param string|null $geometryN The WKT of the expected result, or NULL if an exception is expected. * @param int $srid The SRID of the geometries. */ + #[DataProvider('providerGeometryN')] public function testGeometryN(string $geometry, int $n, ?string $geometryN, int $srid) : void { if ($geometryN === null) { diff --git a/tests/GeometryEngineTest.php b/tests/GeometryEngineTest.php index a7b4adf..1bb2261 100644 --- a/tests/GeometryEngineTest.php +++ b/tests/GeometryEngineTest.php @@ -21,6 +21,7 @@ use Brick\Geo\Polygon; use Brick\Geo\Surface; use LogicException; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests for GeometryEngine implementations. @@ -28,12 +29,11 @@ class GeometryEngineTest extends AbstractTestCase { /** - * @dataProvider providerUnion - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerUnion')] public function testUnion(string $geometry1, string $geometry2, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -70,12 +70,11 @@ public static function providerUnion() : array } /** - * @dataProvider providerDifference - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerDifference')] public function testDifference(string $geometry1, string $geometry2, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -101,11 +100,10 @@ public static function providerDifference() : array } /** - * @dataProvider providerEnvelope - * * @param string $geometry The WKT of the geometry to test. * @param string $envelope The WKT of the expected envelope. */ + #[DataProvider('providerEnvelope')] public function testEnvelope(string $geometry, string $envelope) : void { $geometryEngine = $this->getGeometryEngine(); @@ -126,11 +124,10 @@ public static function providerEnvelope() : array } /** - * @dataProvider providerLength - * * @param string $wkt The WKT of the Curve or MultiCurve to test. * @param float $length The expected length. */ + #[DataProvider('providerLength')] public function testLength(string $wkt, float $length) : void { $geometryEngine = $this->getGeometryEngine(); @@ -170,11 +167,10 @@ public static function providerLength() : array } /** - * @dataProvider providerArea - * * @param string $wkt The WKT of the Surface to test. * @param float $area The expected area. */ + #[DataProvider('providerArea')] public function testArea(string $wkt, float $area) : void { $geometryEngine = $this->getGeometryEngine(); @@ -209,12 +205,11 @@ public static function providerArea() : array } /** - * @dataProvider providerAzimuth - * * @param string $observerWkt The WKT of the point, representing the observer location. * @param string $subjectWkt The WKT of the point, representing the subject location. * @param float|null $azimuthExpected The expected azimuth, or null if an exception is expected. */ + #[DataProvider('providerAzimuth')] public function testAzimuth(string $observerWkt, string $subjectWkt, ?float $azimuthExpected): void { $geometryEngine = $this->getGeometryEngine(); @@ -246,13 +241,12 @@ public static function providerAzimuth(): array } /** - * @dataProvider providerCentroid - * * @param string $wkt The WKT of the geometry to calculate centroid for. * @param float $centroidX Expected `x` coordinate of the geometry centroid. * @param float $centroidY Expected `y` coordinate of the geometry centroid. * @param string[]|null $supportedEngines The engines that support this test, or null for all engines. */ + #[DataProvider('providerCentroid')] public function testCentroid(string $wkt, float $centroidX, float $centroidY, ?array $supportedEngines) : void { $geometryEngine = $this->getGeometryEngine(); @@ -290,10 +284,9 @@ public static function providerCentroid() : array } /** - * @dataProvider providerPointOnSurface - * * @param string $wkt The WKT of the Surface or MultiSurface to test. */ + #[DataProvider('providerPointOnSurface')] public function testPointOnSurface(string $wkt) : void { $geometryEngine = $this->getGeometryEngine(); @@ -329,11 +322,10 @@ public static function providerPointOnSurface() : array } /** - * @dataProvider providerBoundary - * * @param string $geometry The WKT of the geometry to test. * @param string $boundary The WKT of the expected boundary. */ + #[DataProvider('providerBoundary')] public function testBoundary(string $geometry, string $boundary) : void { $geometryEngine = $this->getGeometryEngine(); @@ -368,11 +360,10 @@ public static function providerBoundary() : array } /** - * @dataProvider providerIsValid - * * @param string $geometry The WKT of the geometry to test. * @param bool $isValid Whether the geometry is valid. */ + #[DataProvider('providerIsValid')] public function testIsValid(string $geometry, bool $isValid) : void { $geometryEngine = $this->getGeometryEngine(); @@ -401,11 +392,10 @@ public static function providerIsValid() : array } /** - * @dataProvider providerMakeValid - * * @param string $geometryWKT The WKT of the geometry to test. * @param string $validGeometryWKT The WKT of the expected geometry. */ + #[DataProvider('providerMakeValid')] public function testMakeValid(string $geometryWKT, string $validGeometryWKT) : void { $geometryEngine = $this->getGeometryEngine(); @@ -446,11 +436,10 @@ public static function providerMakeValid() : array } /** - * @dataProvider providerIsClosed - * * @param string $wkt The WKT of the Curve or MultiCurve to test. * @param bool $isClosed Whether the Curve is closed. */ + #[DataProvider('providerIsClosed')] public function testIsClosed(string $wkt, bool $isClosed) : void { $geometryEngine = $this->getGeometryEngine(); @@ -500,11 +489,10 @@ public static function providerIsClosed() : array } /** - * @dataProvider providerIsSimple - * * @param string $geometry The WKT of the geometry to test. * @param bool $isSimple Whether the geometry is simple. */ + #[DataProvider('providerIsSimple')] public function testIsSimple(string $geometry, bool $isSimple) : void { $geometryEngine = $this->getGeometryEngine(); @@ -537,11 +525,10 @@ public static function providerIsSimple() : array } /** - * @dataProvider providerIsRing - * * @param string $wkt The WKT of the Curve to test. * @param bool $isRing Whether the Curve is a ring. */ + #[DataProvider('providerIsRing')] public function testIsRing(string $wkt, bool $isRing) : void { $geometryEngine = $this->getGeometryEngine(); @@ -595,12 +582,11 @@ public static function providerIsRing() : array } /** - * @dataProvider providerEquals - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $equals Whether the geometries are spatially equal. */ + #[DataProvider('providerEquals')] public function testEquals(string $geometry1, string $geometry2, bool $equals) : void { $geometryEngine = $this->getGeometryEngine(); @@ -634,12 +620,11 @@ public static function providerEquals() : array } /** - * @dataProvider providerDisjoint - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $disjoint Whether the geometries are spatially disjoint. */ + #[DataProvider('providerDisjoint')] public function testDisjoint(string $geometry1, string $geometry2, bool $disjoint) : void { $geometryEngine = $this->getGeometryEngine(); @@ -665,12 +650,11 @@ public static function providerDisjoint() : array } /** - * @dataProvider providerIntersects - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $intersects Whether the geometries spatially intersect. */ + #[DataProvider('providerIntersects')] public function testIntersects(string $geometry1, string $geometry2, bool $intersects) : void { $geometryEngine = $this->getGeometryEngine(); @@ -696,12 +680,11 @@ public static function providerIntersects() : array } /** - * @dataProvider providerTouches - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $touches Whether the geometries spatially touch. */ + #[DataProvider('providerTouches')] public function testTouches(string $geometry1, string $geometry2, bool $touches) : void { $geometryEngine = $this->getGeometryEngine(); @@ -729,12 +712,11 @@ public static function providerTouches() : array } /** - * @dataProvider providerCrosses - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $crosses Whether the geometries spatially cross. */ + #[DataProvider('providerCrosses')] public function testCrosses(string $geometry1, string $geometry2, bool $crosses) : void { $geometryEngine = $this->getGeometryEngine(); @@ -762,12 +744,11 @@ public static function providerCrosses() : array } /** - * @dataProvider providerWithin - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $within Whether the first geometry is within the second one. */ + #[DataProvider('providerWithin')] public function testWithin(string $geometry1, string $geometry2, bool $within) : void { $geometryEngine = $this->getGeometryEngine(); @@ -790,12 +771,11 @@ public static function providerWithin() : array } /** - * @dataProvider providerContains - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $contains Whether the first geometry contains the second one. */ + #[DataProvider('providerContains')] public function testContains(string $geometry1, string $geometry2, bool $contains) : void { $geometryEngine = $this->getGeometryEngine(); @@ -818,12 +798,11 @@ public static function providerContains() : array } /** - * @dataProvider providerOverlaps - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param bool $overlaps Whether the first geometry overlaps the second one. */ + #[DataProvider('providerOverlaps')] public function testOverlaps(string $geometry1, string $geometry2, bool $overlaps) : void { $geometryEngine = $this->getGeometryEngine(); @@ -843,13 +822,12 @@ public static function providerOverlaps() : array } /** - * @dataProvider providerRelate - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param string $matrix The intersection matrix pattern. * @param bool $relate Whether the first geometry is spatially related to the second one. */ + #[DataProvider('providerRelate')] public function testRelate(string $geometry1, string $geometry2, string $matrix, bool $relate) : void { $geometryEngine = $this->getGeometryEngine(); @@ -875,12 +853,11 @@ public static function providerRelate() : array } /** - * @dataProvider providerLocateAlong - * * @param string $geometry The WKT of the base geometry. * @param float $measure The test measure. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerLocateAlong')] public function testLocateAlong(string $geometry, float $measure, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -901,13 +878,12 @@ public static function providerLocateAlong() : array } /** - * @dataProvider providerLocateBetween - * * @param string $geometry The WKT of the geometry to test. * @param float $mStart The start measure. * @param float $mEnd The end measure. * @param string $result The WKT of the second geometry. */ + #[DataProvider('providerLocateBetween')] public function testLocateBetween(string $geometry, float $mStart, float $mEnd, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -928,12 +904,11 @@ public static function providerLocateBetween() : array } /** - * @dataProvider providerDistance - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param float $distance The distance between the geometries. */ + #[DataProvider('providerDistance')] public function testDistance(string $geometry1, string $geometry2, float $distance) : void { $geometryEngine = $this->getGeometryEngine(); @@ -953,11 +928,10 @@ public static function providerDistance() : array } /** - * @dataProvider providerBuffer - * * @param string $geometry The WKT of the base geometry. * @param float $distance The distance of the buffer. */ + #[DataProvider('providerBuffer')] public function testBuffer(string $geometry, float $distance) : void { $geometryEngine = $this->getGeometryEngine(); @@ -986,11 +960,10 @@ public static function providerBuffer() : array } /** - * @dataProvider providerConvexHull - * * @param string $geometry The WKT of the base geometry. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerConvexHull')] public function testConvexHull(string $geometry, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1015,12 +988,11 @@ public static function providerConvexHull() : array } /** - * @dataProvider providerIntersection - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerIntersection')] public function testIntersection(string $geometry1, string $geometry2, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1043,12 +1015,11 @@ public static function providerIntersection() : array } /** - * @dataProvider providerSymDifference - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerSymDifference')] public function testSymDifference(string $geometry1, string $geometry2, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1070,12 +1041,11 @@ public static function providerSymDifference() : array } /** - * @dataProvider providerSnapToGrid - * * @param string $geometry The WKT of the geometry to test. * @param float $size The grid size. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerSnapToGrid')] public function testSnapToGrid(string $geometry, float $size, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1103,12 +1073,11 @@ public static function providerSnapToGrid() : array } /** - * @dataProvider providerSimplify - * * @param string $geometry The WKT of the geometry to test. * @param float $tolerance The tolerance. * @param string $result The WKT of the result geometry. */ + #[DataProvider('providerSimplify')] public function testSimplify(string$geometry, float $tolerance, string $result) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1132,12 +1101,11 @@ public static function providerSimplify() : array } /** - * @dataProvider providerMaxDistance - * * @param string $geometry1 The WKT of the first geometry. * @param string $geometry2 The WKT of the second geometry. * @param float $maxDistance The expected value. */ + #[DataProvider('providerMaxDistance')] public function testMaxDistance(string $geometry1, string $geometry2, float $maxDistance) : void { $geometryEngine = $this->getGeometryEngine(); @@ -1161,9 +1129,7 @@ public static function providerMaxDistance() : array ]; } - /** - * @dataProvider providerTransform - */ + #[DataProvider('providerTransform')] public function testTransform(string $originalWKT, int $originalSRID, int $targetSRID, string $expectedWKT) : void { $geometryEngine = $this->getGeometryEngine(); diff --git a/tests/GeometryTest.php b/tests/GeometryTest.php index b7182fe..6ab1d2d 100644 --- a/tests/GeometryTest.php +++ b/tests/GeometryTest.php @@ -9,6 +9,7 @@ use Brick\Geo\IO\WKBTools; use Brick\Geo\Geometry; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for Geometry. @@ -16,10 +17,9 @@ class GeometryTest extends AbstractTestCase { /** - * @dataProvider providerTextBinary - * * @param string $text The WKT of the geometry to test. */ + #[DataProvider('providerTextBinary')] public function testFromAsText(string $text) : void { $geometry = Geometry::fromText($text); @@ -40,12 +40,11 @@ public function testFromTextOnWrongSubclassThrowsException() : void } /** - * @dataProvider providerTextBinary - * * @param string $text The WKT of the geometry under test. * @param string $bigEndianBinary The big endian WKB of the geometry under test. * @param string $littleEndianBinary The little endian WKB of the geometry under test. */ + #[DataProvider('providerTextBinary')] public function testFromBinary(string $text, string $bigEndianBinary, string $littleEndianBinary) : void { foreach ([$bigEndianBinary, $littleEndianBinary] as $binary) { @@ -62,12 +61,11 @@ public function testFromBinary(string $text, string $bigEndianBinary, string $li } /** - * @dataProvider providerTextBinary - * * @param string $text The WKT of the geometry under test. * @param string $bigEndianBinary The big endian WKB of the geometry under test. * @param string $littleEndianBinary The little endian WKB of the geometry under test. */ + #[DataProvider('providerTextBinary')] public function testAsBinary(string $text, string $bigEndianBinary, string $littleEndianBinary) : void { $machineByteOrder = WKBTools::getMachineByteOrder(); @@ -94,9 +92,7 @@ public static function providerTextBinary() : array ]; } - /** - * @dataProvider providerDimension - */ + #[DataProvider('providerDimension')] public function testDimension(string $geometry, int $dimension) : void { $geometry = Geometry::fromText($geometry); @@ -155,11 +151,10 @@ public static function providerDimension() : array } /** - * @dataProvider providerCoordinateDimension - * * @param string $geometry The WKT of the geometry to test. * @param int $coordinateDimension The expected coordinate dimension. */ + #[DataProvider('providerCoordinateDimension')] public function testCoordinateDimension(string $geometry, int $coordinateDimension) : void { self::assertSame($coordinateDimension, Geometry::fromText($geometry)->coordinateDimension()); @@ -180,11 +175,10 @@ public static function providerCoordinateDimension() : array } /** - * @dataProvider providerSpatialDimension - * * @param string $geometry The WKT of the geometry to test. * @param int $spatialDimension The expected spatial dimension. */ + #[DataProvider('providerSpatialDimension')] public function testSpatialDimension(string $geometry, int $spatialDimension) : void { self::assertSame($spatialDimension, Geometry::fromText($geometry)->spatialDimension()); @@ -205,11 +199,10 @@ public static function providerSpatialDimension() : array } /** - * @dataProvider providerGeometryType - * * @param string $geometry The WKT of the geometry to test. * @param string $geometryType The expected geometry type. */ + #[DataProvider('providerGeometryType')] public function testGeometryType(string $geometry, string $geometryType) : void { $geometry = Geometry::fromText($geometry); @@ -274,9 +267,7 @@ public static function providerGeometryType() : array ]; } - /** - * @dataProvider providerSRID - */ + #[DataProvider('providerSRID')] public function testSRID(int $srid) : void { self::assertSame($srid, Geometry::fromText('POINT EMPTY', $srid)->SRID()); @@ -291,11 +282,10 @@ public static function providerSRID() : array } /** - * @dataProvider providerIsEmpty - * * @param string $geometry The WKT of the geometry to test. * @param bool $isEmpty Whether the geometry is empty. */ + #[DataProvider('providerIsEmpty')] public function testIsEmpty(string $geometry, bool $isEmpty) : void { self::assertSame($isEmpty, Geometry::fromText($geometry)->isEmpty()); @@ -315,12 +305,11 @@ public static function providerIsEmpty() : array } /** - * @dataProvider providerDimensionality - * * @param string $geometry The geometry to test. * @param bool $is3D Whether the geometry has a Z coordinate. * @param bool $isMeasured Whether the geometry has a M coordinate. */ + #[DataProvider('providerDimensionality')] public function testDimensionality(string $geometry, bool $is3D, bool $isMeasured) : void { self::assertSame($is3D, Geometry::fromText($geometry)->is3D()); @@ -341,9 +330,7 @@ public static function providerDimensionality() : array ]; } - /** - * @dataProvider providerWithSRID - */ + #[DataProvider('providerWithSRID')] public function testWithSRID(string $wkt): void { $geometry = Geometry::fromText($wkt)->withSRID(4326); @@ -398,11 +385,10 @@ public static function providerWithSRID(): array } /** - * @dataProvider providerToArray - * * @param string $geometry The WKT of the geometry to test. * @param array $array The expected result array. */ + #[DataProvider('providerToArray')] public function testToArray(string $geometry, array $array) : void { $this->castToFloat($array); @@ -432,9 +418,7 @@ public static function providerToArray() : array ]; } - /** - * @dataProvider providerIsIdenticalTo - */ + #[DataProvider('providerIsIdenticalTo')] public function testIsIdenticalTo(string $wkt1, string $wkt2, bool $identical) : void { $geometry1 = Geometry::fromText($wkt1); @@ -443,9 +427,7 @@ public function testIsIdenticalTo(string $wkt1, string $wkt2, bool $identical) : self::assertSame($identical, $geometry1->isIdenticalTo($geometry2)); } - /** - * @dataProvider providerIsIdenticalTo - */ + #[DataProvider('providerIsIdenticalTo')] public function testIsIdenticalToDifferentSRIDs(string $wkt1, string $wkt2) : void { $geometry1 = Geometry::fromText($wkt1, 1); diff --git a/tests/IO/EWKBReaderTest.php b/tests/IO/EWKBReaderTest.php index c014241..9beb26b 100644 --- a/tests/IO/EWKBReaderTest.php +++ b/tests/IO/EWKBReaderTest.php @@ -6,6 +6,7 @@ use Brick\Geo\IO\EWKBReader; use Brick\Geo\IO\EWKTWriter; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class EWKBReader. @@ -13,11 +14,10 @@ class EWKBReaderTest extends EWKBAbstractTestCase { /** - * @dataProvider providerRead - * * @param string $ewkb The EWKB to read, hex-encoded. * @param string $ewkt The expected EWKT output. */ + #[DataProvider('providerRead')] public function testRead(string $ewkb, string $ewkt) : void { $reader = new EWKBReader(); diff --git a/tests/IO/EWKBWriterTest.php b/tests/IO/EWKBWriterTest.php index aa56460..d657a19 100644 --- a/tests/IO/EWKBWriterTest.php +++ b/tests/IO/EWKBWriterTest.php @@ -9,6 +9,7 @@ use Brick\Geo\IO\EWKTReader; use Brick\Geo\IO\WKBByteOrder; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class EWKBWriter. @@ -16,12 +17,11 @@ class EWKBWriterTest extends EWKBAbstractTestCase { /** - * @dataProvider providerWrite - * * @param string $ewkt The EWKT to read. * @param string $ewkb The expected EWKB output, hex-encoded. * @param WKBByteOrder $byteOrder The byte order to use. */ + #[DataProvider('providerWrite')] public function testWrite(string $ewkt, string $ewkb, WKBByteOrder $byteOrder) : void { $writer = new EWKBWriter(); @@ -54,9 +54,7 @@ public static function providerWrite() : \Generator } } - /** - * @dataProvider providerWriteEmptyPointThrowsException - */ + #[DataProvider('providerWriteEmptyPointThrowsException')] public function testWriteEmptyPointThrowsException(Point $point) : void { $writer = new EWKBWriter(); diff --git a/tests/IO/EWKTReaderTest.php b/tests/IO/EWKTReaderTest.php index 3637a22..b75ba3b 100644 --- a/tests/IO/EWKTReaderTest.php +++ b/tests/IO/EWKTReaderTest.php @@ -5,6 +5,7 @@ namespace Brick\Geo\Tests\IO; use Brick\Geo\IO\EWKTReader; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class EWKTReader. @@ -12,14 +13,13 @@ class EWKTReaderTest extends EWKTAbstractTestCase { /** - * @dataProvider providerRead - * * @param string $ewkt The EWKT to read. * @param array $coords The expected Point coordinates. * @param bool $is3D Whether the resulting Point has a Z coordinate. * @param bool $isMeasured Whether the resulting Point has a M coordinate. * @param int $srid The expected SRID. */ + #[DataProvider('providerRead')] public function testRead(string $ewkt, array $coords, bool $is3D, bool $isMeasured, int $srid) : void { $geometry = (new EWKTReader())->read($ewkt); diff --git a/tests/IO/EWKTWriterTest.php b/tests/IO/EWKTWriterTest.php index 03f9f22..c37b59c 100644 --- a/tests/IO/EWKTWriterTest.php +++ b/tests/IO/EWKTWriterTest.php @@ -7,6 +7,7 @@ use Brick\Geo\CoordinateSystem; use Brick\Geo\GeometryCollection; use Brick\Geo\IO\EWKTWriter; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class EWKTWriter. @@ -14,11 +15,10 @@ class EWKTWriterTest extends EWKTAbstractTestCase { /** - * @dataProvider providerPrettyPrint - * * @param bool $prettyPrint Whether to set the prettyPrint parameter. * @param string $ewkt The expected result EWKT. */ + #[DataProvider('providerPrettyPrint')] public function testPrettyPrint(bool $prettyPrint, string $ewkt) : void { $writer = new EWKTWriter(); @@ -38,13 +38,12 @@ public static function providerPrettyPrint() : array } /** - * @dataProvider providerPointWKT - * * @param string $wkt The expected WKT. * @param array $coords The Point coordinates. * @param bool $is3D Whether the Point has a Z coordinate. * @param bool $isMeasured Whether the Point has a M coordinate. */ + #[DataProvider('providerPointWKT')] public function testWritePoint(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -57,13 +56,12 @@ public function testWritePoint(string $wkt, array $coords, bool $is3D, bool $isM } /** - * @dataProvider providerLineStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The LineString coordinates. * @param bool $is3D Whether the LineString has Z coordinates. * @param bool $isMeasured Whether the LineString has M coordinates. */ + #[DataProvider('providerLineStringWKT')] public function testWriteLineString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -76,13 +74,12 @@ public function testWriteLineString(string $wkt, array $coords, bool $is3D, bool } /** - * @dataProvider providerCircularStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The CircularString coordinates. * @param bool $is3D Whether the CircularString has Z coordinates. * @param bool $isMeasured Whether the CircularString has M coordinates. */ + #[DataProvider('providerCircularStringWKT')] public function testWriteCircularString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -95,13 +92,12 @@ public function testWriteCircularString(string $wkt, array $coords, bool $is3D, } /** - * @dataProvider providerCompoundCurveWKT - * * @param string $wkt The expected WKT. * @param array $coords The CompoundCurve coordinates. * @param bool $is3D Whether the CompoundCurve has Z coordinates. * @param bool $isMeasured Whether the CompoundCurve has M coordinates. */ + #[DataProvider('providerCompoundCurveWKT')] public function testWriteCompoundCurve(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -114,13 +110,12 @@ public function testWriteCompoundCurve(string $wkt, array $coords, bool $is3D, b } /** - * @dataProvider providerPolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The Polygon coordinates. * @param bool $is3D Whether the Polygon has Z coordinates. * @param bool $isMeasured Whether the Polygon has M coordinates. */ + #[DataProvider('providerPolygonWKT')] public function testWritePolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -133,13 +128,12 @@ public function testWritePolygon(string $wkt, array $coords, bool $is3D, bool $i } /** - * @dataProvider providerTriangleWKT - * * @param string $wkt The expected WKT. * @param array $coords The Triangle coordinates. * @param bool $is3D Whether the Triangle has Z coordinates. * @param bool $isMeasured Whether the Triangle has M coordinates. */ + #[DataProvider('providerTriangleWKT')] public function testWriteTriangle(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -152,13 +146,12 @@ public function testWriteTriangle(string $wkt, array $coords, bool $is3D, bool $ } /** - * @dataProvider providerCurvePolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The Polygon coordinates. * @param bool $is3D Whether the Polygon has Z coordinates. * @param bool $isMeasured Whether the Polygon has M coordinates. */ + #[DataProvider('providerCurvePolygonWKT')] public function testWriteCurvePolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -171,13 +164,12 @@ public function testWriteCurvePolygon(string $wkt, array $coords, bool $is3D, bo } /** - * @dataProvider providerPolyhedralSurfaceWKT - * * @param string $wkt The expected WKT. * @param array $coords The PolyhedralSurface coordinates. * @param bool $is3D Whether the PolyhedralSurface has Z coordinates. * @param bool $isMeasured Whether the PolyhedralSurface has M coordinates. */ + #[DataProvider('providerPolyhedralSurfaceWKT')] public function testWritePolyhedralSurface(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -190,13 +182,12 @@ public function testWritePolyhedralSurface(string $wkt, array $coords, bool $is3 } /** - * @dataProvider providerTINWKT - * * @param string $wkt The expected WKT. * @param array $coords The TIN coordinates. * @param bool $is3D Whether the TIN has Z coordinates. * @param bool $isMeasured Whether the TIN has M coordinates. */ + #[DataProvider('providerTINWKT')] public function testWriteTIN(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -209,13 +200,12 @@ public function testWriteTIN(string $wkt, array $coords, bool $is3D, bool $isMea } /** - * @dataProvider providerMultiPointWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiPoint coordinates. * @param bool $is3D Whether the MultiPoint has Z coordinates. * @param bool $isMeasured Whether the MultiPoint has M coordinates. */ + #[DataProvider('providerMultiPointWKT')] public function testWriteMultiPoint(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -228,13 +218,12 @@ public function testWriteMultiPoint(string $wkt, array $coords, bool $is3D, bool } /** - * @dataProvider providerMultiLineStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiLineString coordinates. * @param bool $is3D Whether the MultiLineString has Z coordinates. * @param bool $isMeasured Whether the MultiLineString has M coordinates. */ + #[DataProvider('providerMultiLineStringWKT')] public function testWriteMultiLineString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -247,13 +236,12 @@ public function testWriteMultiLineString(string $wkt, array $coords, bool $is3D, } /** - * @dataProvider providerMultiPolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiPolygon coordinates. * @param bool $is3D Whether the MultiPolygon has Z coordinates. * @param bool $isMeasured Whether the MultiPolygon has M coordinates. */ + #[DataProvider('providerMultiPolygonWKT')] public function testWriteMultiPolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); @@ -266,13 +254,12 @@ public function testWriteMultiPolygon(string $wkt, array $coords, bool $is3D, bo } /** - * @dataProvider providerGeometryCollectionWKT - * * @param string $wkt The expected WKT. * @param array $coords The GeometryCollection coordinates. * @param bool $is3D Whether the GeometryCollection has Z coordinates. * @param bool $isMeasured Whether the GeometryCollection has M coordinates. */ + #[DataProvider('providerGeometryCollectionWKT')] public function testWriteGeometryCollection(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new EWKTWriter(); diff --git a/tests/IO/GeoJSONReaderTest.php b/tests/IO/GeoJSONReaderTest.php index c7191a4..32d66d6 100644 --- a/tests/IO/GeoJSONReaderTest.php +++ b/tests/IO/GeoJSONReaderTest.php @@ -8,18 +8,18 @@ use Brick\Geo\IO\GeoJSON\Feature; use Brick\Geo\IO\GeoJSON\FeatureCollection; use Brick\Geo\IO\GeoJSONReader; +use PHPUnit\Framework\Attributes\DataProvider; use stdClass; class GeoJSONReaderTest extends GeoJSONAbstractTestCase { /** - * @dataProvider providerReadGeometry - * * @param string $geojson The GeoJSON to read. * @param array $coords The expected Geometry coordinates. * @param bool $is3D Whether the resulting Geometry has a Z coordinate. * @param bool $lenient Whether to be lenient about case-sensitivity. */ + #[DataProvider('providerReadGeometry')] public function testReadGeometry(string $geojson, array $coords, bool $is3D, bool $lenient) : void { $geometry = (new GeoJSONReader($lenient))->read($geojson); @@ -35,14 +35,13 @@ public static function providerReadGeometry() : \Generator } /** - * @dataProvider providerReadFeature - * * @param string $geojson The GeoJSON to read. * @param stdClass|null $properties The contained properties. * @param array|null $coords The expected Geometry coordinates, or null if the Feature has no geometry. * @param bool $is3D Whether the resulting Geometry has a Z coordinate. * @param bool $lenient Whether to be lenient about case-sensitivity. */ + #[DataProvider('providerReadFeature')] public function testReadFeature(string $geojson, ?stdClass $properties, ?array $coords, bool $is3D, bool $lenient) : void { $feature = (new GeoJSONReader($lenient))->read($geojson); @@ -68,13 +67,12 @@ public static function providerReadFeature() : \Generator } /** - * @dataProvider providerReadFeatureCollection - * * @param string $geojson The GeoJSON to read. * @param array[] $coords The expected Point coordinates. * @param bool[] $is3D Whether the resulting Point has a Z coordinate. * @param bool $lenient Whether to be lenient about case-sensitivity. */ + #[DataProvider('providerReadFeatureCollection')] public function testReadFeatureCollection(string $geojson, array $properties, array $coords, array $is3D, bool $lenient) : void { $featureCollection = (new GeoJSONReader($lenient))->read($geojson); @@ -96,9 +94,7 @@ public static function providerReadFeatureCollection() : \Generator } } - /** - * @dataProvider providerNonLenientReadWrongCaseType - */ + #[DataProvider('providerNonLenientReadWrongCaseType')] public function testNonLenientReadWrongCaseType(string $geojson, string $expectedExceptionMessage) : void { $reader = new GeoJSONReader(); diff --git a/tests/IO/GeoJSONWriterTest.php b/tests/IO/GeoJSONWriterTest.php index 4350339..2408163 100644 --- a/tests/IO/GeoJSONWriterTest.php +++ b/tests/IO/GeoJSONWriterTest.php @@ -8,14 +8,13 @@ use Brick\Geo\IO\GeoJSONWriter; use Brick\Geo\Point; use Brick\Geo\Polygon; +use PHPUnit\Framework\Attributes\DataProvider; class GeoJSONWriterTest extends GeoJSONAbstractTestCase { - /** - * @dataProvider providerGeometryGeoJSON - * @dataProvider providerFeatureGeoJSON - * @dataProvider providerFeatureCollectionGeoJSON - */ + #[DataProvider('providerGeometryGeoJSON')] + #[DataProvider('providerFeatureGeoJSON')] + #[DataProvider('providerFeatureCollectionGeoJSON')] public function testWriteGeometry(string $geojson) : void { $geometry = (new GeoJSONReader())->read($geojson); diff --git a/tests/IO/WKBReaderTest.php b/tests/IO/WKBReaderTest.php index ed3041a..9d3eece 100644 --- a/tests/IO/WKBReaderTest.php +++ b/tests/IO/WKBReaderTest.php @@ -5,6 +5,7 @@ namespace Brick\Geo\Tests\IO; use Brick\Geo\IO\WKBReader; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class WKBReader. @@ -12,11 +13,10 @@ class WKBReaderTest extends WKBAbstractTestCase { /** - * @dataProvider providerRead - * * @param string $wkb The WKB to read, hex-encoded. * @param string $wkt The expected WKT output. */ + #[DataProvider('providerRead')] public function testRead(string $wkb, string $wkt) : void { $reader = new WKBReader(); diff --git a/tests/IO/WKBWriterTest.php b/tests/IO/WKBWriterTest.php index af23718..6038b76 100644 --- a/tests/IO/WKBWriterTest.php +++ b/tests/IO/WKBWriterTest.php @@ -9,6 +9,7 @@ use Brick\Geo\IO\WKBWriter; use Brick\Geo\IO\WKTReader; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class WKBWriter. @@ -16,12 +17,11 @@ class WKBWriterTest extends WKBAbstractTestCase { /** - * @dataProvider providerWrite - * * @param string $wkt The WKT to read. * @param string $wkb The expected WKB output, hex-encoded. * @param WKBByteOrder $byteOrder The byte order to use. */ + #[DataProvider('providerWrite')] public function testWrite(string $wkt, string $wkb, WKBByteOrder $byteOrder) : void { $writer = new WKBWriter(); @@ -46,9 +46,7 @@ public static function providerWrite() : \Generator } } - /** - * @dataProvider providerWriteEmptyPointThrowsException - */ + #[DataProvider('providerWriteEmptyPointThrowsException')] public function testWriteEmptyPointThrowsException(Point $point) : void { $writer = new WKBWriter(); diff --git a/tests/IO/WKTReaderTest.php b/tests/IO/WKTReaderTest.php index b13e442..d8b18d9 100644 --- a/tests/IO/WKTReaderTest.php +++ b/tests/IO/WKTReaderTest.php @@ -5,6 +5,7 @@ namespace Brick\Geo\Tests\IO; use Brick\Geo\IO\WKTReader; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class WKTReader. @@ -12,14 +13,13 @@ class WKTReaderTest extends WKTAbstractTestCase { /** - * @dataProvider providerRead - * * @param string $wkt The WKT to read. * @param array $coords The expected Point coordinates. * @param bool $is3D Whether the resulting Point has a Z coordinate. * @param bool $isMeasured Whether the resulting Point has a M coordinate. * @param int $srid The SRID to use. */ + #[DataProvider('providerRead')] public function testRead(string $wkt, array $coords, bool $is3D, bool $isMeasured, int $srid) : void { $geometry = (new WKTReader())->read($wkt, $srid); diff --git a/tests/IO/WKTWriterTest.php b/tests/IO/WKTWriterTest.php index 5e2b35b..519c392 100644 --- a/tests/IO/WKTWriterTest.php +++ b/tests/IO/WKTWriterTest.php @@ -8,6 +8,7 @@ use Brick\Geo\GeometryCollection; use Brick\Geo\IO\WKTWriter; use Brick\Geo\MultiLineString; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class WKTWriter. @@ -15,12 +16,11 @@ class WKTWriterTest extends WKTAbstractTestCase { /** - * @dataProvider providerPrettyPrint - * * @param bool $is3D Whether to use Z coordinates. * @param bool $prettyPrint Whether to set the prettyPrint parameter. * @param string $wkt The expected result WKT. */ + #[DataProvider('providerPrettyPrint')] public function testPrettyPrint(bool $is3D, bool $prettyPrint, string $wkt) : void { $writer = new WKTWriter(); @@ -54,13 +54,12 @@ public static function providerPrettyPrint() : array } /** - * @dataProvider providerPointWKT - * * @param string $wkt The expected WKT. * @param array $coords The Point coordinates. * @param bool $is3D Whether the Point has a Z coordinate. * @param bool $isMeasured Whether the Point has a M coordinate. */ + #[DataProvider('providerPointWKT')] public function testWritePoint(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -73,13 +72,12 @@ public function testWritePoint(string $wkt, array $coords, bool $is3D, bool $isM } /** - * @dataProvider providerLineStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The LineString coordinates. * @param bool $is3D Whether the LineString has Z coordinates. * @param bool $isMeasured Whether the LineString has M coordinates. */ + #[DataProvider('providerLineStringWKT')] public function testWriteLineString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -92,13 +90,12 @@ public function testWriteLineString(string $wkt, array $coords, bool $is3D, bool } /** - * @dataProvider providerCircularStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The CircularString coordinates. * @param bool $is3D Whether the CircularString has Z coordinates. * @param bool $isMeasured Whether the CircularString has M coordinates. */ + #[DataProvider('providerCircularStringWKT')] public function testWriteCircularString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -111,13 +108,12 @@ public function testWriteCircularString(string $wkt, array $coords, bool $is3D, } /** - * @dataProvider providerCompoundCurveWKT - * * @param string $wkt The expected WKT. * @param array $coords The CompoundCurve coordinates. * @param bool $is3D Whether the CompoundCurve has Z coordinates. * @param bool $isMeasured Whether the CompoundCurve has M coordinates. */ + #[DataProvider('providerCompoundCurveWKT')] public function testWriteCompoundCurve(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -130,13 +126,12 @@ public function testWriteCompoundCurve(string $wkt, array $coords, bool $is3D, b } /** - * @dataProvider providerPolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The Polygon coordinates. * @param bool $is3D Whether the Polygon has Z coordinates. * @param bool $isMeasured Whether the Polygon has M coordinates. */ + #[DataProvider('providerPolygonWKT')] public function testWritePolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -149,13 +144,12 @@ public function testWritePolygon(string $wkt, array $coords, bool $is3D, bool $i } /** - * @dataProvider providerTriangleWKT - * * @param string $wkt The expected WKT. * @param array $coords The Triangle coordinates. * @param bool $is3D Whether the Triangle has Z coordinates. * @param bool $isMeasured Whether the Triangle has M coordinates. */ + #[DataProvider('providerTriangleWKT')] public function testWriteTriangle(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -168,13 +162,12 @@ public function testWriteTriangle(string $wkt, array $coords, bool $is3D, bool $ } /** - * @dataProvider providerCurvePolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The Polygon coordinates. * @param bool $is3D Whether the Polygon has Z coordinates. * @param bool $isMeasured Whether the Polygon has M coordinates. */ + #[DataProvider('providerCurvePolygonWKT')] public function testWriteCurvePolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -187,13 +180,12 @@ public function testWriteCurvePolygon(string $wkt, array $coords, bool $is3D, bo } /** - * @dataProvider providerPolyhedralSurfaceWKT - * * @param string $wkt The expected WKT. * @param array $coords The PolyhedralSurface coordinates. * @param bool $is3D Whether the PolyhedralSurface has Z coordinates. * @param bool $isMeasured Whether the PolyhedralSurface has M coordinates. */ + #[DataProvider('providerPolyhedralSurfaceWKT')] public function testWritePolyhedralSurface(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -206,13 +198,12 @@ public function testWritePolyhedralSurface(string $wkt, array $coords, bool $is3 } /** - * @dataProvider providerTINWKT - * * @param string $wkt The expected WKT. * @param array $coords The TIN coordinates. * @param bool $is3D Whether the TIN has Z coordinates. * @param bool $isMeasured Whether the TIN has M coordinates. */ + #[DataProvider('providerTINWKT')] public function testWriteTIN(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -225,13 +216,12 @@ public function testWriteTIN(string $wkt, array $coords, bool $is3D, bool $isMea } /** - * @dataProvider providerMultiPointWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiPoint coordinates. * @param bool $is3D Whether the MultiPoint has Z coordinates. * @param bool $isMeasured Whether the MultiPoint has M coordinates. */ + #[DataProvider('providerMultiPointWKT')] public function testWriteMultiPoint(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -244,13 +234,12 @@ public function testWriteMultiPoint(string $wkt, array $coords, bool $is3D, bool } /** - * @dataProvider providerMultiLineStringWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiLineString coordinates. * @param bool $is3D Whether the MultiLineString has Z coordinates. * @param bool $isMeasured Whether the MultiLineString has M coordinates. */ + #[DataProvider('providerMultiLineStringWKT')] public function testWriteMultiLineString(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -263,13 +252,12 @@ public function testWriteMultiLineString(string $wkt, array $coords, bool $is3D, } /** - * @dataProvider providerMultiPolygonWKT - * * @param string $wkt The expected WKT. * @param array $coords The MultiPolygon coordinates. * @param bool $is3D Whether the MultiPolygon has Z coordinates. * @param bool $isMeasured Whether the MultiPolygon has M coordinates. */ + #[DataProvider('providerMultiPolygonWKT')] public function testWriteMultiPolygon(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -282,13 +270,12 @@ public function testWriteMultiPolygon(string $wkt, array $coords, bool $is3D, bo } /** - * @dataProvider providerGeometryCollectionWKT - * * @param string $wkt The expected WKT. * @param array $coords The GeometryCollection coordinates. * @param bool $is3D Whether the GeometryCollection has Z coordinates. * @param bool $isMeasured Whether the GeometryCollection has M coordinates. */ + #[DataProvider('providerGeometryCollectionWKT')] public function testWriteGeometryCollection(string $wkt, array $coords, bool $is3D, bool $isMeasured) : void { $writer = new WKTWriter(); @@ -308,9 +295,7 @@ public function testWriteGeometryCollection(string $wkt, array $coords, bool $is self::assertSame($wkt, $writer->write($geometryCollection)); } - /** - * @dataProvider providerWriteEmptyGeometryCollection - */ + #[DataProvider('providerWriteEmptyGeometryCollection')] public function testWriteEmptyGeometryCollection(string $wkt) : void { $writer = new WKTWriter(); diff --git a/tests/LineStringTest.php b/tests/LineStringTest.php index 59a9a74..db7e38f 100644 --- a/tests/LineStringTest.php +++ b/tests/LineStringTest.php @@ -8,15 +8,14 @@ use Brick\Geo\Exception\NoSuchGeometryException; use Brick\Geo\LineString; use Brick\Geo\Point; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class LineString. */ class LineStringTest extends AbstractTestCase { - /** - * @dataProvider providerNumPoints - */ + #[DataProvider('providerNumPoints')] public function testNumPoints(string $lineString, int $numPoints) : void { $lineString = LineString::fromText($lineString); @@ -37,9 +36,7 @@ public static function providerNumPoints() : array ]; } - /** - * @dataProvider providerPointN - */ + #[DataProvider('providerPointN')] public function testPointN(string $lineString, int $n, string $pointN) : void { foreach ([0, 1] as $srid) { @@ -64,9 +61,7 @@ public static function providerPointN() : array ]; } - /** - * @dataProvider providerInvalidPointNThrowsException - */ + #[DataProvider('providerInvalidPointNThrowsException')] public function testInvalidPointNThrowsException(string $lineString, int $n) : void { $this->expectException(NoSuchGeometryException::class); @@ -105,9 +100,7 @@ public function testInterfaces() : void ], iterator_to_array($lineString)); } - /** - * @dataProvider providerRectangle - */ + #[DataProvider('providerRectangle')] public function testRectangle(string $point1, string $point2, string $expected) : void { $point1 = Point::fromText($point1); @@ -127,9 +120,7 @@ public static function providerRectangle() : array ]; } - /** - * @dataProvider providerRectangleWithInvalidPoints - */ + #[DataProvider('providerRectangleWithInvalidPoints')] public function testRectangleWithInvalidPoints(string $point1, string $point2, int $srid1 = 0, int $srid2 = 0) : void { $point1 = Point::fromText($point1, $srid1); diff --git a/tests/MultiCurveTest.php b/tests/MultiCurveTest.php index 261c5ed..09a6e47 100644 --- a/tests/MultiCurveTest.php +++ b/tests/MultiCurveTest.php @@ -6,6 +6,7 @@ use Brick\Geo\Exception\UnexpectedGeometryException; use Brick\Geo\MultiCurve; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class MultiCurve. @@ -13,10 +14,9 @@ class MultiCurveTest extends AbstractTestCase { /** - * @dataProvider providerInvalidFromText - * * @param string $wkt A valid WKT, for a non-multicurve geometry. */ + #[DataProvider('providerInvalidFromText')] public function testInvalidFromText(string $wkt) : void { $this->expectException(UnexpectedGeometryException::class); @@ -34,10 +34,9 @@ public static function providerInvalidFromText() : array } /** - * @dataProvider providerInvalidFromBinary - * * @param string $wkb A valid HEX WKB, for a non-multicurve geometry. */ + #[DataProvider('providerInvalidFromBinary')] public function testInvalidFromBinary(string $wkb) : void { $this->expectException(UnexpectedGeometryException::class); diff --git a/tests/MultiSurfaceTest.php b/tests/MultiSurfaceTest.php index 34c73b1..ab4dd68 100644 --- a/tests/MultiSurfaceTest.php +++ b/tests/MultiSurfaceTest.php @@ -6,6 +6,7 @@ use Brick\Geo\Exception\UnexpectedGeometryException; use Brick\Geo\MultiSurface; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class MultiSurface. @@ -13,10 +14,9 @@ class MultiSurfaceTest extends AbstractTestCase { /** - * @dataProvider providerInvalidFromText - * * @param string $wkt A valid WKT, for a non-multisurface geometry. */ + #[DataProvider('providerInvalidFromText')] public function testInvalidFromText(string $wkt) : void { $this->expectException(UnexpectedGeometryException::class); @@ -34,10 +34,9 @@ public static function providerInvalidFromText() : array } /** - * @dataProvider providerInvalidFromBinary - * * @param string $wkb A valid HEX WKB, for a non-multisurface geometry. */ + #[DataProvider('providerInvalidFromBinary')] public function testInvalidFromBinary(string $wkb) : void { $this->expectException(UnexpectedGeometryException::class); diff --git a/tests/PointTest.php b/tests/PointTest.php index 347b55d..190fbc2 100644 --- a/tests/PointTest.php +++ b/tests/PointTest.php @@ -8,6 +8,7 @@ use Brick\Geo\Exception\InvalidGeometryException; use Brick\Geo\Point; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class Point. @@ -15,10 +16,9 @@ class PointTest extends AbstractTestCase { /** - * @dataProvider providerConstructorWithInvalidCoordinates - * * @param float[] $coords */ + #[DataProvider('providerConstructorWithInvalidCoordinates')] public function testConstructorWithInvalidCoordinates( bool $hasZ, bool $hasM, @@ -179,11 +179,10 @@ public function testXyzmEmptyWithSRID() : void } /** - * @dataProvider providerToArrayAndInterfaces - * * @param string $point The WKT of the point to test. * @param array $coordinates The expected coordinates. */ + #[DataProvider('providerToArrayAndInterfaces')] public function testToArrayAndInterfaces(string $point, array $coordinates) : void { $point = Point::fromText($point); diff --git a/tests/PolygonTest.php b/tests/PolygonTest.php index 17aaf41..62e594a 100644 --- a/tests/PolygonTest.php +++ b/tests/PolygonTest.php @@ -10,15 +10,14 @@ use Brick\Geo\CoordinateSystem; use Brick\Geo\LineString; use Brick\Geo\Polygon; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class Polygon. */ class PolygonTest extends AbstractTestCase { - /** - * @dataProvider providerConstructorEmpty - */ + #[DataProvider('providerConstructorEmpty')] public function testConstructorEmpty(bool $is3D, bool $isMeasured, int $srid) : void { $cs = new CoordinateSystem($is3D, $isMeasured, $srid); @@ -45,10 +44,9 @@ public static function providerConstructorEmpty() : array } /** - * @dataProvider providerConstructor - * * @param string[] $ringsWKT */ + #[DataProvider('providerConstructor')] public function testConstructor(array $ringsWKT, string $polygonWKT, bool $hasZ, bool $hasM, int $srid) : void { $rings = []; @@ -79,8 +77,6 @@ public static function providerConstructor() : \Generator } /** - * @dataProvider providerConstructorWithCoordinateSystemMix - * * @param string $ringWKT The WKT of the outer ring of the polygon. * @param int $ringSRID The SRID of the outer ring of the polygon. * @param bool $hasZ Whether the coordinate system has Z coordinates. @@ -88,6 +84,7 @@ public static function providerConstructor() : \Generator * @param int $srid The SRID of the coordinate system. * @param string $message The expected exception message, optional. */ + #[DataProvider('providerConstructorWithCoordinateSystemMix')] public function testConstructorWithCoordinateSystemMix(string $ringWKT, int $ringSRID, bool $hasZ, bool $hasM, int $srid, string $message = '') : void { $this->expectException(CoordinateSystemException::class); @@ -127,10 +124,9 @@ public static function providerConstructorWithCoordinateSystemMix() : array } /** - * @dataProvider providerOf - * * @param string[] $ringsWKT */ + #[DataProvider('providerOf')] public function testOf(array $ringsWKT, string $polygonWKT, int $srid) : void { $rings = []; @@ -159,9 +155,7 @@ public static function providerOf() : \Generator } } - /** - * @dataProvider providerOfWithCoordinateSystemMix - */ + #[DataProvider('providerOfWithCoordinateSystemMix')] public function testOfWithCoordinateSystemMix(string $outerRingWKT, string $innerRingWKT, int $outerRingSRID, int $innerRingSRID) : void { $outerRing = LineString::fromText($outerRingWKT, $outerRingSRID); @@ -186,13 +180,12 @@ public static function providerOfWithCoordinateSystemMix() : array } /** - * @dataProvider providerRings - * * @param string $polygonWKT The WKT of the Polygon to test. * @param string|null $exteriorRingWKT The WKT of the exterior ring, or null if the Polygon is empty. * @param string[] $interiorRingWKTs The WKT of the interior rings. * @param int $srid The SRID of the geometries. */ + #[DataProvider('providerRings')] public function testRings(string $polygonWKT, ?string $exteriorRingWKT, array $interiorRingWKTs, int $srid) : void { $polygon = Polygon::fromText($polygonWKT, $srid); diff --git a/tests/PolyhedralSurfaceTest.php b/tests/PolyhedralSurfaceTest.php index aca5ec5..98b948c 100644 --- a/tests/PolyhedralSurfaceTest.php +++ b/tests/PolyhedralSurfaceTest.php @@ -8,6 +8,7 @@ use Brick\Geo\CoordinateSystem; use Brick\Geo\Polygon; use Brick\Geo\PolyhedralSurface; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class PolyhedralSurface. @@ -15,13 +16,12 @@ class PolyhedralSurfaceTest extends AbstractTestCase { /** - * @dataProvider providerCreate - * * @param string[] $patchesWKT The WKT of the patches (polygons) that compose the PolyhedralSurface. * @param bool $is3D Whether the patches have Z coordinates. * @param bool $isMeasured Whether the patches have M coordinates. * @param string $polyhedralSurfaceWKT The WKT of the expected PolyhedralSurface. */ + #[DataProvider('providerCreate')] public function testCreate(array $patchesWKT, bool $is3D, bool $isMeasured, string $polyhedralSurfaceWKT) : void { foreach ([0, 1] as $srid) { @@ -44,11 +44,10 @@ public static function providerCreate() : array } /** - * @dataProvider providerNumPatches - * * @param string $polyhedralSurface The WKT of the PolyhedralSurface to test. * @param int $numPatches The expected number of patches. */ + #[DataProvider('providerNumPatches')] public function testNumPatches(string $polyhedralSurface, int $numPatches) : void { self::assertSame($numPatches, PolyhedralSurface::fromText($polyhedralSurface)->numPatches()); @@ -69,13 +68,12 @@ public static function providerNumPatches() : array } /** - * @dataProvider providerPatchN - * * @param string $polyhedralSurface The WKT of the PolyhedralSurface to test. * @param int $n The patch number. * @param string|null $patchN The WKT of the expected patch, or NULL if an exception is expected. * @param int $srid The SRID of the geometries. */ + #[DataProvider('providerPatchN')] public function testPatchN(string $polyhedralSurface, int $n, ?string $patchN, int $srid) : void { if ($patchN === null) { diff --git a/tests/Proxy/PointProxyTest.php b/tests/Proxy/PointProxyTest.php index f1aca5a..b50a82a 100644 --- a/tests/Proxy/PointProxyTest.php +++ b/tests/Proxy/PointProxyTest.php @@ -7,15 +7,14 @@ use Brick\Geo\Point; use Brick\Geo\Proxy\PointProxy; use Brick\Geo\Tests\AbstractTestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Unit tests for class PointProxy. */ class PointProxyTest extends AbstractTestCase { - /** - * @dataProvider providerProxy - */ + #[DataProvider('providerProxy')] public function testProxy(string $data, bool $isBinary, bool $is3D, bool $isMeasured, array $coords) : void { if ($isBinary) {