create(); $event = Event::factory()->for($org)->create(); $artist = Artist::factory()->create(['organisation_id' => $org->id]); $eng = ArtistEngagement::create([ 'artist_id' => $artist->id, 'event_id' => $event->id, 'booking_status' => ArtistEngagementStatus::Confirmed->value, ]); $stage = Stage::factory()->for($event)->create(); $start = CarbonImmutable::now(); return Performance::create([ 'engagement_id' => $eng->id, 'event_id' => $event->id, 'stage_id' => $stage->id, 'start_at' => $start, 'end_at' => $start->addHour(), ]); } public function test_version_starts_at_zero_on_create(): void { $perf = $this->makePerformance(); $this->assertSame(0, $perf->fresh()->version); } public function test_version_increments_by_one_per_update(): void { $perf = $this->makePerformance(); $perf->update(['notes' => 'first edit']); $this->assertSame(1, $perf->fresh()->version); $perf->update(['notes' => 'second edit']); $this->assertSame(2, $perf->fresh()->version); } public function test_version_does_not_increment_on_no_op_save(): void { $perf = $this->makePerformance(); // Saving without dirty attributes should not bump version. $perf->save(); $this->assertSame(0, $perf->fresh()->version); } }