Initial commit
This commit is contained in:
144
tests/Support/CreatesDomainData.php
Normal file
144
tests/Support/CreatesDomainData.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use App\Models\Band;
|
||||
use App\Models\Category;
|
||||
use App\Models\Contest;
|
||||
use App\Models\EvaluationRuleSet;
|
||||
use App\Models\EvaluationRun;
|
||||
use App\Models\EdiBand;
|
||||
use App\Models\EdiCategory;
|
||||
use App\Models\Cty;
|
||||
use App\Models\CountryWwl;
|
||||
use App\Models\ContestParameter;
|
||||
use App\Models\Log;
|
||||
use App\Models\LogQso;
|
||||
use App\Models\LogResult;
|
||||
use App\Models\LogOverride;
|
||||
use App\Models\QsoOverride;
|
||||
use App\Models\QsoResult;
|
||||
use App\Models\NewsPost;
|
||||
use App\Models\File;
|
||||
use App\Models\PowerCategory;
|
||||
use App\Models\Round;
|
||||
|
||||
trait CreatesDomainData
|
||||
{
|
||||
protected function createRuleSet(array $overrides = []): EvaluationRuleSet
|
||||
{
|
||||
return EvaluationRuleSet::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createContest(array $overrides = []): Contest
|
||||
{
|
||||
return Contest::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createRound(array $overrides = []): Round
|
||||
{
|
||||
return Round::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createLog(array $overrides = []): Log
|
||||
{
|
||||
return Log::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createBand(array $overrides = []): Band
|
||||
{
|
||||
return Band::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createCategory(array $overrides = []): Category
|
||||
{
|
||||
return Category::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createPowerCategory(array $overrides = []): PowerCategory
|
||||
{
|
||||
return PowerCategory::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createEdiBand(array $overrides = []): EdiBand
|
||||
{
|
||||
return EdiBand::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createEdiCategory(array $overrides = []): EdiCategory
|
||||
{
|
||||
return EdiCategory::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createCty(array $overrides = []): Cty
|
||||
{
|
||||
return Cty::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createCountryWwl(array $overrides = []): CountryWwl
|
||||
{
|
||||
return CountryWwl::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createContestParameter(array $overrides = []): ContestParameter
|
||||
{
|
||||
return ContestParameter::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createLogQso(array $overrides = []): LogQso
|
||||
{
|
||||
return LogQso::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createLogResult(array $overrides = []): LogResult
|
||||
{
|
||||
return LogResult::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createLogOverride(array $overrides = []): LogOverride
|
||||
{
|
||||
return LogOverride::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createQsoOverride(array $overrides = []): QsoOverride
|
||||
{
|
||||
return QsoOverride::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createQsoResult(array $overrides = []): QsoResult
|
||||
{
|
||||
return QsoResult::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createNewsPost(array $overrides = []): NewsPost
|
||||
{
|
||||
return NewsPost::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createFile(array $overrides = []): File
|
||||
{
|
||||
return File::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function createEvaluationRun(array $overrides = []): EvaluationRun
|
||||
{
|
||||
return EvaluationRun::factory()->create($overrides);
|
||||
}
|
||||
|
||||
protected function attachRoundRelations(
|
||||
Round $round,
|
||||
array $bands = [],
|
||||
array $categories = [],
|
||||
array $powerCategories = []
|
||||
): void {
|
||||
if ($bands) {
|
||||
$round->bands()->sync($bands);
|
||||
}
|
||||
if ($categories) {
|
||||
$round->categories()->sync($categories);
|
||||
}
|
||||
if ($powerCategories) {
|
||||
$round->powerCategories()->sync($powerCategories);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user