@@ -14,7 +14,7 @@ class GeometryCastTest extends TestCase
1414 use DatabaseMigrations;
1515
1616 /** @test */
17- public function it_serializes_and_deserializes_geometry_object (): void
17+ public function it_creates_model_record (): void
1818 {
1919 $ point = new Point (180 , 0 );
2020
@@ -26,6 +26,52 @@ public function it_serializes_and_deserializes_geometry_object(): void
2626 $ this ->assertEquals ($ point , $ testPlace ->point );
2727 }
2828
29+ /** @test */
30+ public function it_creates_model_record_with_geometry_null (): void
31+ {
32+ /** @var TestPlace $testPlace */
33+ $ testPlace = TestPlace::factory ()->create ([
34+ 'point ' => null ,
35+ ]);
36+
37+ $ this ->assertEquals (null , $ testPlace ->point );
38+ }
39+
40+ /** @test */
41+ public function it_updates_model_record (): void
42+ {
43+ $ point = new Point (180 , 0 );
44+ $ point2 = new Point (0 , 0 );
45+
46+ /** @var TestPlace $testPlace */
47+ $ testPlace = TestPlace::factory ()->create ([
48+ 'point ' => $ point ,
49+ ]);
50+
51+ $ testPlace ->update ([
52+ 'point ' => $ point2 ,
53+ ]);
54+
55+ $ this ->assertEquals ($ point2 , $ testPlace ->point );
56+ }
57+
58+ /** @test */
59+ public function it_updates_model_record_with_geometry_null (): void
60+ {
61+ $ point = new Point (180 , 0 );
62+
63+ /** @var TestPlace $testPlace */
64+ $ testPlace = TestPlace::factory ()->create ([
65+ 'point ' => $ point ,
66+ ]);
67+
68+ $ testPlace ->update ([
69+ 'point ' => null ,
70+ ]);
71+
72+ $ this ->assertEquals (null , $ testPlace ->point );
73+ }
74+
2975 /** @test */
3076 public function it_gets_original_geometry_field (): void
3177 {
@@ -61,12 +107,11 @@ public function it_gets_dirty_when_geometry_is_changed(): void
61107 public function it_does_not_get_dirty_when_geometry_is_not_changed (): void
62108 {
63109 $ point = new Point (180 , 0 );
64- $ point2 = new Point (180 , 0 );
65110
66111 /** @var TestPlace $testPlace */
67112 $ testPlace = TestPlace::factory ()->create ([
68113 'point ' => $ point ,
69- ])-> fresh () ;
114+ ]);
70115
71116 $ this ->assertFalse ($ testPlace ->isDirty ('point ' ));
72117 }
@@ -138,15 +183,4 @@ public function it_throws_exception_when_deserializing_invalid_geometry_object()
138183
139184 $ testPlace ->getAttribute ('point_with_line_string_cast ' );
140185 }
141-
142- /** @test */
143- public function it_serializes_and_deserializes_null (): void
144- {
145- /** @var TestPlace $testPlace */
146- $ testPlace = TestPlace::factory ()->create ([
147- 'point ' => null ,
148- ]);
149-
150- $ this ->assertEquals (null , $ testPlace ->point );
151- }
152186}
0 commit comments