@@ -305,6 +305,8 @@ public function testShapeName(): void
305
305
$ this ->assertEquals ('Point ' , $ obj ->getShapeName ());
306
306
$ obj = new ShapeRecord (ShapeType::Null);
307
307
$ this ->assertEquals ('Null Shape ' , $ obj ->getShapeName ());
308
+ $ obj = new ShapeRecord (ShapeType::Unknown);
309
+ $ this ->assertEquals ('Unknown Shape ' , $ obj ->getShapeName ());
308
310
}
309
311
310
312
/**
@@ -314,14 +316,13 @@ public function testShapeName(): void
314
316
*
315
317
* @dataProvider shapesProvider
316
318
*/
317
- public function testShapeSaveLoad (int $ shapeType , array $ points ): void
319
+ public function testShapeSaveLoad (ShapeType $ shapeType , array $ points ): void
318
320
{
319
- $ shapeEnum = ShapeType::tryFrom ($ shapeType ) ?? ShapeType::Unknown;
320
- $ filename = './data/test_shape- ' . $ shapeType . '.* ' ;
321
- $ shp = new ShapeFile ($ shapeEnum );
321
+ $ filename = './data/test_shape- ' . $ shapeType ->value . '.* ' ;
322
+ $ shp = new ShapeFile ($ shapeType );
322
323
$ shp ->setDBFHeader ([['ID ' , 'N ' , 19 , 0 ], ['DESC ' , 'C ' , 14 , 0 ]]);
323
324
324
- $ record0 = new ShapeRecord ($ shapeEnum );
325
+ $ record0 = new ShapeRecord ($ shapeType );
325
326
326
327
foreach ($ points as $ point ) {
327
328
$ record0 ->addPoint ($ point [0 ], $ point [1 ]);
@@ -331,7 +332,7 @@ public function testShapeSaveLoad(int $shapeType, array $points): void
331
332
332
333
$ shp ->saveToFile ($ filename );
333
334
334
- $ shp2 = new ShapeFile ($ shapeEnum );
335
+ $ shp2 = new ShapeFile ($ shapeType );
335
336
$ shp2 ->loadFromFile ($ filename );
336
337
337
338
$ this ->assertEquals (count ($ shp ->records ), count ($ shp2 ->records ));
@@ -355,7 +356,7 @@ public function testShapeSaveLoad(int $shapeType, array $points): void
355
356
/**
356
357
* Data provider for save/load testing.
357
358
*
358
- * @psalm-return list<array{int , list<array{mixed[], int}>}>
359
+ * @psalm-return list<array{ShapeType , list<array{mixed[], int}>}>
359
360
*/
360
361
public static function shapesProvider (): array
361
362
{
@@ -384,18 +385,18 @@ public static function shapesProvider(): array
384
385
];
385
386
386
387
return [
387
- [ShapeType::Point-> value , $ pointsForPointType ],
388
- [ShapeType::PolyLine-> value , $ pointsForPolyLineType ],
389
- [ShapeType::Polygon-> value , $ pointsForPolygonType ],
390
- [ShapeType::MultiPoint-> value , $ pointsForMultiPointType ],
391
- [ShapeType::PointZ-> value , $ pointsForPointType ],
392
- [ShapeType::PolyLineZ-> value , $ pointsForPolyLineType ],
393
- [ShapeType::PolygonZ-> value , $ pointsForPolygonType ],
394
- [ShapeType::MultiPointZ-> value , $ pointsForMultiPointType ],
395
- [ShapeType::PointM-> value , $ pointsForPointType ],
396
- [ShapeType::PolyLineM-> value , $ pointsForPolyLineType ],
397
- [ShapeType::PolygonM-> value , $ pointsForPolygonType ],
398
- [ShapeType::MultiPointM-> value , $ pointsForMultiPointType ],
388
+ [ShapeType::Point, $ pointsForPointType ],
389
+ [ShapeType::PolyLine, $ pointsForPolyLineType ],
390
+ [ShapeType::Polygon, $ pointsForPolygonType ],
391
+ [ShapeType::MultiPoint, $ pointsForMultiPointType ],
392
+ [ShapeType::PointZ, $ pointsForPointType ],
393
+ [ShapeType::PolyLineZ, $ pointsForPolyLineType ],
394
+ [ShapeType::PolygonZ, $ pointsForPolygonType ],
395
+ [ShapeType::MultiPointZ, $ pointsForMultiPointType ],
396
+ [ShapeType::PointM, $ pointsForPointType ],
397
+ [ShapeType::PolyLineM, $ pointsForPolyLineType ],
398
+ [ShapeType::PolygonM, $ pointsForPolygonType ],
399
+ [ShapeType::MultiPointM, $ pointsForMultiPointType ],
399
400
];
400
401
}
401
402
0 commit comments