diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0d007d4..3fa00cc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,53 +1,39 @@ - - - - - + + + + src/ + + + src/config + + + + + + + ./tests/ - - - - - src/ - - - src/config - - - - - - - - + diff --git a/src/Geometry.php b/src/Geometry.php index f8c7453..c604cd9 100644 --- a/src/Geometry.php +++ b/src/Geometry.php @@ -126,6 +126,6 @@ public function parse(object|string $data, ?string $type = null): GeometryProxy // If running in Laravel, then use the IoC return is_null($this->app) ? new $geometry_class($geometry, $this->mapper) - : $this->app->make($geometry_class, [$geometry, $this->mapper]); + : $this->app->make($geometry_class, ['geometry' => $geometry, 'mapper' => $this->mapper]); } } diff --git a/src/GeometryServiceProvider.php b/src/GeometryServiceProvider.php index 3686724..0e32cc2 100644 --- a/src/GeometryServiceProvider.php +++ b/src/GeometryServiceProvider.php @@ -29,7 +29,7 @@ public function boot() public function register() { $this->app->singleton('geometry', function ($app) { - return $app->make(Geometry::class, [new geoPHP(), new TypeMapper(), $app]); + return $app->make(Geometry::class, ['geometry' => new geoPHP(), 'mapper' => new TypeMapper(), 'app' => $app]); }); } } diff --git a/tests/GeometryTest.php b/tests/GeometryTest.php index d7ccb01..5490880 100644 --- a/tests/GeometryTest.php +++ b/tests/GeometryTest.php @@ -144,8 +144,8 @@ public function it_uses_laravel_to_resolve_classes_if_was_provided() ->withArgs([ 'Spinen\Geometry\Geometries\Polygon', [ - $polygon, - $this->mapper_mock, + 'geometry' => $polygon, + 'mapper' => $this->mapper_mock, ], ]) ->andReturn(new GeometryProxy($polygon, $this->mapper_mock)); @@ -340,12 +340,144 @@ public function it_raises_exception_when_building_name_to_proxy_class_for_null_g */ public function it_raises_exception_when_building_name_to_proxy_class_that_does_not_exist() { - $this->markTestSkipped('Now that typecasting a Geometry, there is no way to pass an invalid class to trigger this test'); - $this->expectException(RuntimeException::class); $this->geometry->buildGeometryClassName(new class extends GlobalGeometry { + public function area() + { + // Just a stub for area() method. + } + + public function boundary() + { + // Just a stub for boundary() method. + } + + public function centroid() + { + // Just a stub for centroid() method. + } + + public function length() + { + // Just a stub for length() method. + } + + public function y() + { + // Just a stub for y() method. + } + + public function x() + { + // Just a stub for x() method. + } + + public function numGeometries() + { + // Just a stub for numGeometries() method. + } + + public function geometryN($n) + { + // Just a stub for geometryN() method. + } + + public function startPoint() + { + // Just a stub for startPoint() method. + } + + public function endPoint() + { + // Just a stub for endPoint() method. + } + + public function isRing() + { + // Just a stub for isRing() method. + } + + public function isClosed() + { + // Just a stub for isClosed() method. + } + + public function numPoints() + { + // Just a stub for numPoints() method. + } + + public function pointN($n) + { + // Just a stub for pointN() method. + } + + public function exteriorRing() + { + // Just a stub for exteriorRing() method. + } + + public function numInteriorRings() + { + // Just a stub for numInteriorRings() method. + } + + public function interiorRingN($n) + { + // Just a stub for interiorRingN() method. + } + + public function dimension() + { + // Just a stub for dimension() method. + } + + public function equals($geom) + { + // Just a stub for equals() method. + } + + public function isEmpty() + { + // Just a stub for isEmpty() method. + } + + public function isSimple() + { + // Just a stub for isSimple() method. + } + + public function getBBox() + { + // Just a stub for getBBox() method. + } + + public function asArray() + { + // Just a stub for asArray() method. + } + + public function getPoints() + { + // Just a stub for getPoints() method. + } + + public function explode() + { + // Just a stub for explode() method. + } + + public function greatCircleLength() + { + // Just a stub for greatCircleLength() method. + } + + public function haversineLength() + { + // Just a stub for haversineLength() method. + } }); } }