|
109 | 109 | TestPlace::insert(array_merge(TestPlace::factory()->definition(), [ |
110 | 110 | 'point_with_line_string_cast' => DB::raw('POINT(0, 180)'), |
111 | 111 | ])); |
| 112 | + /** @var TestPlace $testPlace */ |
| 113 | + $testPlace = TestPlace::firstOrFail(); |
112 | 114 |
|
113 | | - expect(function (): void { |
114 | | - TestPlace::firstOrFail(); |
| 115 | + expect(function () use ($testPlace): void { |
| 116 | + $testPlace->getAttribute('point_with_line_string_cast'); |
115 | 117 | })->toThrow(InvalidArgumentException::class); |
116 | 118 | }); |
117 | 119 |
|
|
124 | 126 |
|
125 | 127 | expect($testPlace->point)->toEqual($point); |
126 | 128 | }); |
127 | | - |
128 | | -it('serializes and json encodes a model record with geometry', function (): void { |
129 | | - // Arrange |
130 | | - $point = new Point(0, 180); |
131 | | - /** @var TestPlace $testPlace */ |
132 | | - $testPlace = TestPlace::factory()->make(['point' => $point]); |
133 | | - |
134 | | - // Act |
135 | | - // @phpstan-ignore-next-line |
136 | | - $recoveredTestPlace = unserialize(json_decode(json_encode(serialize($testPlace)))); |
137 | | - |
138 | | - // Assert |
139 | | - expect($recoveredTestPlace)->toEqual($testPlace); |
140 | | -}); |
141 | | - |
142 | | -it('serializes and json encodes a model record with geometry when retrieving from database', function (): void { |
143 | | - // Arrange |
144 | | - $point = new Point(0, 180); |
145 | | - /** @var TestPlace $testPlace */ |
146 | | - $testPlace = TestPlace::factory()->create(['point' => $point]); |
147 | | - $testPlaceFromDb = TestPlace::find($testPlace->id); |
148 | | - |
149 | | - // Act |
150 | | - // @phpstan-ignore-next-line |
151 | | - $recoveredTestPlace = unserialize(json_decode(json_encode(serialize($testPlaceFromDb)))); |
152 | | - |
153 | | - // Assert |
154 | | - expect($recoveredTestPlace)->toEqual($testPlaceFromDb); |
155 | | -}); |
0 commit comments