mock = Mockery::mock(DoublerSync::class); app()->instance(DoublerSync::class, $this->mock); }); afterEach(function () { Mockery::close(); }); it('syncs doublers if an entry is created that makes or adds to a doubler', function () { $event = Event::factory()->create(); $student = Student::factory()->create(); $audition1 = Audition::factory()->forEvent($event)->create(); $audition2 = Audition::factory()->forEvent($event)->create(); $audition3 = Audition::factory()->forEvent($event)->create(); $entryMaker = app(CreateEntry::class); $this->mock->shouldReceive('__invoke')->twice(); $entryMaker($student, $audition1); $entryMaker($student, $audition2); $entryMaker($student, $audition3); }); it('syncs doublers when an entry is updated', function () { $this->mock->shouldReceive('__invoke')->once(); $entry = Entry::factory()->create(); $entry->update(['audition_id' => Audition::factory()->create()->id]); }); it('syncs doublers when an entry is deleted', function () { $this->mock->shouldReceive('__invoke')->once(); $entry = Entry::factory()->create(); $entry->delete(); });