@@ -14,7 +14,7 @@ class GeometryCastTest extends TestCase
14
14
use DatabaseMigrations;
15
15
16
16
/** @test */
17
- public function it_serializes_and_deserializes_geometry_object (): void
17
+ public function it_creates_model_record (): void
18
18
{
19
19
$ point = new Point (180 , 0 );
20
20
@@ -26,6 +26,52 @@ public function it_serializes_and_deserializes_geometry_object(): void
26
26
$ this ->assertEquals ($ point , $ testPlace ->point );
27
27
}
28
28
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
+
29
75
/** @test */
30
76
public function it_gets_original_geometry_field (): void
31
77
{
@@ -61,12 +107,11 @@ public function it_gets_dirty_when_geometry_is_changed(): void
61
107
public function it_does_not_get_dirty_when_geometry_is_not_changed (): void
62
108
{
63
109
$ point = new Point (180 , 0 );
64
- $ point2 = new Point (180 , 0 );
65
110
66
111
/** @var TestPlace $testPlace */
67
112
$ testPlace = TestPlace::factory ()->create ([
68
113
'point ' => $ point ,
69
- ])-> fresh () ;
114
+ ]);
70
115
71
116
$ this ->assertFalse ($ testPlace ->isDirty ('point ' ));
72
117
}
@@ -138,15 +183,4 @@ public function it_throws_exception_when_deserializing_invalid_geometry_object()
138
183
139
184
$ testPlace ->getAttribute ('point_with_line_string_cast ' );
140
185
}
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
- }
152
186
}
0 commit comments