diff --git a/tests/Objects/PointTest.php b/tests/Objects/PointTest.php index a2689c3..4bee1bc 100644 --- a/tests/Objects/PointTest.php +++ b/tests/Objects/PointTest.php @@ -27,6 +27,20 @@ public function it_stores_point(): void $this->assertDatabaseCount($testPlace->getTable(), 1); } + /** @test */ + public function it_casts_when_retrieved_from_database(): void + { + /** @var TestPlace $testPlace */ + $testPlace = TestPlace::factory()->create([ + 'point' => new Point(180, 0), + ]); + $testPlace2 = TestPlace::find($testPlace->id); + $this->assertEquals($testPlace->point, $testPlace2->point); + $this->assertEquals($testPlace, $testPlace2); + dump($testPlace); + dump($testPlace2); + } + /** @test */ public function it_stores_point_from_json(): void { diff --git a/tests/TestFactories/TestPlaceFactory.php b/tests/TestFactories/TestPlaceFactory.php index e7fcac0..8ab8a6c 100644 --- a/tests/TestFactories/TestPlaceFactory.php +++ b/tests/TestFactories/TestPlaceFactory.php @@ -18,8 +18,15 @@ class TestPlaceFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->streetName, - 'address' => $this->faker->address, + 'name' => $this->faker->streetName, + 'address' => $this->faker->address, + 'multi_point' => null, + 'line_string' => null, + 'multi_line_string' => null, + 'polygon' => null, + 'multi_polygon' => null, + 'geometry_collection' => null, + 'point_with_line_string_cast' => null, ]; } }