Write tests - Write tests for what was done to this point that will be kept #11
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\ScoringGuide;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -16,8 +17,45 @@ class SubscoreDefinitionFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
|
$sg = ScoringGuide::factory()->create();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
//
|
'scoring_guide_id' => $sg->id,
|
||||||
|
'name' => $this->faker->word,
|
||||||
|
'max_score' => 100,
|
||||||
|
'weight' => $this->faker->numberBetween(1, 4),
|
||||||
|
'display_order' => $this->faker->numberBetween(1, 20),
|
||||||
|
'tiebreak_order' => $this->faker->numberBetween(1, 20),
|
||||||
|
'for_seating' => 1,
|
||||||
|
'for_advance' => 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
public function seatingOnly(): self
|
||||||
|
{
|
||||||
|
return $this->state(
|
||||||
|
fn (array $attributes) => ['for_advance' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function advanceOnly(): self
|
||||||
|
{
|
||||||
|
return $this->state(
|
||||||
|
fn (array $attributes) => ['for_seating' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayFirst(): self
|
||||||
|
{
|
||||||
|
return $this->state(
|
||||||
|
fn (array $attributes) => ['display_order' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tiebreakFirst(): self
|
||||||
|
{
|
||||||
|
return $this->state(
|
||||||
|
fn (array $attributes) => ['tiebreak_order' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,7 @@ it('has entries', function () {
|
||||||
}
|
}
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
expect($school->entries->count())->toBe(9)
|
expect($school->entries->count())->toBe(9)
|
||||||
->and($school->entries->first())->toBeInstanceOf(Entry::class)
|
->and($school->entries->first())->toBeInstanceOf(Entry::class);
|
||||||
->and($school->entries->first()->student->first_name)->toBe($student->first_name);
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Audition;
|
||||||
|
use App\Models\ScoringGuide;
|
||||||
|
use App\Models\SubscoreDefinition;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('has auditions in score order', function () {
|
||||||
|
// Arrange
|
||||||
|
$scoringGuide = ScoringGuide::factory()->create();
|
||||||
|
Audition::factory()->count(5)->create(['scoring_guide_id' => $scoringGuide->id]);
|
||||||
|
$audition = Audition::factory()->create(['scoring_guide_id' => $scoringGuide->id, 'score_order' => 0]);
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
expect($scoringGuide->auditions->count())->toBe(6)
|
||||||
|
->and($scoringGuide->auditions->first()->id)->toBe($audition->id)
|
||||||
|
->and($scoringGuide->auditions->first())->toBeInstanceOf(Audition::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has subscores', function () {
|
||||||
|
// Arrange
|
||||||
|
$sg = ScoringGuide::factory()->create();
|
||||||
|
SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $sg->id]);
|
||||||
|
// Act & Assert
|
||||||
|
expect($sg->subscores->count())->toBe(5)
|
||||||
|
->and($sg->subscores->first())->toBeInstanceOf(SubscoreDefinition::class);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue