|
126 | 126 |
|
127 | 127 | expect($testPlace->point)->toEqual($point);
|
128 | 128 | });
|
| 129 | + |
| 130 | +it('checks a model record is not dirty after creation', function (): void { |
| 131 | + $point = new Point(0, 180); |
| 132 | + |
| 133 | + /** @var TestPlace $testPlace */ |
| 134 | + $testPlace = TestPlace::factory()->create(['point' => $point]); |
| 135 | + |
| 136 | + expect($testPlace->isDirty())->toBeFalse(); |
| 137 | +}); |
| 138 | + |
| 139 | +it('checks a model record is not dirty after fetch', function (): void { |
| 140 | + $point = new Point(0, 180); |
| 141 | + TestPlace::factory()->create(['point' => $point]); |
| 142 | + |
| 143 | + /** @var TestPlace $testPlace */ |
| 144 | + $testPlace = TestPlace::firstOrFail(); |
| 145 | + |
| 146 | + expect($testPlace->isDirty())->toBeFalse(); |
| 147 | +}); |
| 148 | + |
| 149 | +it('checks a model record is dirty after update from null before save', function (): void { |
| 150 | + $point = new Point(0, 180); |
| 151 | + /** @var TestPlace $testPlace */ |
| 152 | + $testPlace = TestPlace::factory()->create([]); |
| 153 | + |
| 154 | + $testPlace->point = $point; |
| 155 | + |
| 156 | + expect($testPlace->isDirty())->toBeTrue(); |
| 157 | +}); |
| 158 | + |
| 159 | +it('checks a model record is dirty after update before save', function (): void { |
| 160 | + $point = new Point(0, 180); |
| 161 | + $point2 = new Point(0, 0); |
| 162 | + /** @var TestPlace $testPlace */ |
| 163 | + $testPlace = TestPlace::factory()->create(['point' => $point]); |
| 164 | + |
| 165 | + $testPlace->point = $point2; |
| 166 | + |
| 167 | + expect($testPlace->isDirty())->toBeTrue(); |
| 168 | +}); |
| 169 | + |
| 170 | +it('checks a model record is not dirty after update and save', function (): void { |
| 171 | + $point = new Point(0, 180); |
| 172 | + $point2 = new Point(0, 0); |
| 173 | + /** @var TestPlace $testPlace */ |
| 174 | + $testPlace = TestPlace::factory()->create(['point' => $point]); |
| 175 | + |
| 176 | + $testPlace->point = $point2; |
| 177 | + $testPlace->save(); |
| 178 | + |
| 179 | + expect($testPlace->isDirty())->toBeFalse(); |
| 180 | +}); |
| 181 | + |
| 182 | +it('checks a model record is not dirty after update to same value before save', function (): void { |
| 183 | + $point = new Point(0, 180); |
| 184 | + $point2 = new Point(0, 180); |
| 185 | + /** @var TestPlace $testPlace */ |
| 186 | + $testPlace = TestPlace::factory()->create(['point' => $point]); |
| 187 | + |
| 188 | + $testPlace->point = $point2; |
| 189 | + |
| 190 | + expect($testPlace->isDirty())->toBeFalse(); |
| 191 | +}); |
0 commit comments