Add doublers relationship to School model
This commit is contained in:
parent
30667a28c5
commit
bb4785fdbf
|
|
@ -33,6 +33,11 @@ class School extends Model
|
|||
return $this->hasManyThrough(DoublerRequest::class, Student::class);
|
||||
}
|
||||
|
||||
public function doublers()
|
||||
{
|
||||
return $this->hasManyThrough(Doubler::class, Student::class);
|
||||
}
|
||||
|
||||
/** TODO: Remove this and concepts of profile picture */
|
||||
/** @codeCoverageIgnore */
|
||||
public function initialLetterImageURL($bg_color = '4f46e5', $text_color = 'fff'): string
|
||||
|
|
|
|||
|
|
@ -95,3 +95,21 @@ it('returns doubler requests for its students', function () {
|
|||
expect($this->school->doublerRequests()->count())->toEqual(1);
|
||||
|
||||
});
|
||||
|
||||
it('returns doublers for its students', function () {
|
||||
$student = Student::factory()->forSchool($this->school)->create(['grade' => 8]);
|
||||
$audition = Audition::factory()->create(['minimum_grade' => 8, 'maximum_grade' => 8]);
|
||||
$audition2 = Audition::factory()->forEvent($audition->event)->create([
|
||||
'minimum_grade' => 8, 'maximum_grade' => 8,
|
||||
]);
|
||||
$entryCreator = app(\App\Actions\Entries\CreateEntry::class);
|
||||
$entryCreator($student, $audition);
|
||||
$entryCreator($student, $audition2);
|
||||
|
||||
$otherStudent = Student::factory()->create(['grade' => 8]);
|
||||
$entryCreator($otherStudent, $audition);
|
||||
$entryCreator($otherStudent, $audition2);
|
||||
expect(Doubler::count())->toEqual(2);
|
||||
|
||||
expect($this->school->doublers()->count())->toEqual(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue