39 lines
1.5 KiB
PHP
39 lines
1.5 KiB
PHP
<?php
|
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
use App\Models\Audition;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('throws an exception when an invalid mode is requested', function () {
|
|
$auditionService = new \App\Services\AuditionService();
|
|
$this->expectException(\App\Exceptions\AuditionServiceException::class);
|
|
$auditionService->getSubscores(new Audition(), 'invalid_mode');
|
|
});
|
|
it('throws an exception when an invalid sort is requested', function () {
|
|
// Arrange
|
|
$auditionService = new \App\Services\AuditionService();
|
|
$this->expectException(\App\Exceptions\AuditionServiceException::class);
|
|
// Act
|
|
$auditionService->getSubscores(new Audition(), 'seating', 'invalid_sort');
|
|
});
|
|
it('throws an exception when an invalid audition is provided', function () {
|
|
// Arrange
|
|
$auditionService = new \App\Services\AuditionService();
|
|
$this->expectException(\App\Exceptions\AuditionServiceException::class);
|
|
$auditionService->getSubscores(new Audition(), 'seating', 'tiebreak');
|
|
// Act & Assert
|
|
|
|
});
|
|
it('gets subscores for an audition', function () {
|
|
// Arrange
|
|
loadSampleAudition();
|
|
$auditionService = new \App\Services\AuditionService();
|
|
// Act
|
|
$subscores = $auditionService->getSubscores(Audition::find(1000), 'seating', 'tiebreak');
|
|
// Assert
|
|
expect($subscores->toArray())->toBe(Audition::find(1000)->scoringGuide->subscores->where('for_seating', true)->sortBy('tiebreak_order')->toArray());
|
|
});
|