rank('wrong', Audition::factory()->create()); })->throws(TabulationException::class, 'Mode must be seating or advancement'); it('throws an exception if an invalid audition is provided', function () { // Arrange //$ranker = new RankAuditionEntries(new AllJudgesCount()); $ranker = App::make(RankAuditionEntries::class); // Act & Assert $ranker->rank('seating', Audition::factory()->make()); })->throws(TabulationException::class, 'Invalid audition provided'); it('includes all entries of the given mode in the return', function () { $audition = Audition::factory()->create(); $entries = Entry::factory()->seatingOnly()->count(10)->create(['audition_id' => $audition->id]); $otherEntries = Entry::factory()->advanceOnly()->count(10)->create(['audition_id' => $audition->id]); //$ranker = new RankAuditionEntries(new AllJudgesCount()); $ranker = App::make(RankAuditionEntries::class); // Act $return = $ranker->rank('seating', $audition); // Assert foreach ($entries as $entry) { expect($return->pluck('id')->toArray())->toContain($entry->id); } foreach ($otherEntries as $entry) { expect($return->pluck('id')->toArray())->not()->toContain($entry->id); } }); it('places entries in the proper order', function () { // Arrange Artisan::call('cache:clear'); loadSampleAudition(); $judge = User::factory()->create(); Room::find(1000)->addJudge($judge); $entries = Entry::factory()->count(5)->create(['audition_id' => 1000]); $scoreArray1 = [1001 => 90, 1002 => 90, 1003 => 90, 1004 => 90, 1005 => 90]; $scoreArray2 = [1001 => 60, 1002 => 60, 1003 => 60, 1004 => 60, 1005 => 60]; $scoreArray3 = [1001 => 80, 1002 => 80, 1003 => 80, 1004 => 80, 1005 => 80]; $scoreArray4 = [1001 => 100, 1002 => 100, 1003 => 100, 1004 => 100, 1005 => 100]; $scoreArray5 = [1001 => 70, 1002 => 70, 1003 => 70, 1004 => 70, 1005 => 70]; enterScore($judge, $entries[0], $scoreArray1); enterScore($judge, $entries[1], $scoreArray2); enterScore($judge, $entries[2], $scoreArray3); enterScore($judge, $entries[3], $scoreArray4); enterScore($judge, $entries[4], $scoreArray5); Artisan::call('cache:clear'); $ranker = App::make(RankAuditionEntries::class); $expectedOrder = [4, 1, 3, 5, 2]; // Act $return = $ranker->rank('seating', Audition::find(1000)); // Assert expect($return->pluck('id')->toArray())->toBe($expectedOrder); });