diff --git a/tests/Feature/app/Models/DoublerTest.php b/tests/Feature/app/Models/DoublerTest.php new file mode 100644 index 0000000..e152620 --- /dev/null +++ b/tests/Feature/app/Models/DoublerTest.php @@ -0,0 +1,53 @@ +event = Event::factory()->create(); + $this->student = Student::factory()->create(['grade' => 8]); + $this->audition1 = Audition::factory()->create([ + 'minimum_grade' => 8, 'maximum_grade' => 8, 'event_id' => $this->event->id, + ]); + $this->audition2 = \App\Models\Audition::factory()->create([ + 'minimum_grade' => 8, 'maximum_grade' => 8, 'event_id' => $this->event->id, + ]); + $entryCreator = app(CreateEntry::class); + $entryCreator($this->student, $this->audition1); + $entryCreator($this->student, $this->audition2); +}); + +it('can return its student', function () { + expect(Doubler::first()->student->id)->toEqual($this->student->id) + ->and(Doubler::first()->student)->toBeInstanceOf(Student::class); +}); + +it('can return its event', function () { + expect(Doubler::first()->event->id)->toEqual($this->event->id) + ->and(Doubler::first()->event)->toBeInstanceOf(Event::class); +}); + +it('can return its entries', function () { + expect(Doubler::first()->entries()->count())->toEqual(2) + ->and(Doubler::first()->entries()->first())->toBeInstanceOf(Entry::class); +}); + +it('can find a doubler', function () { + expect(Doubler::findDoubler($this->student->id, $this->event->id))->toBeInstanceOf(Doubler::class); +}); + +it('can load doublers for a given event', function () { + Doubler::truncate(); + expect(Doubler::count())->toBe(0); + Doubler::syncForEvent($this->event->id); + expect(Doubler::count())->toBe(1); +});