Initial commit
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Evaluation;
|
||||
|
||||
use App\Jobs\RecalculateOfficialRanksJob;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RecalculateOfficialRanksSixhrModeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_iaru_sixhr_merges_single_and_multi(): void
|
||||
{
|
||||
$ruleSet = $this->createRuleSet(['sixhr_ranking_mode' => 'IARU']);
|
||||
$round = $this->createRound();
|
||||
$run = $this->createEvaluationRun(['round_id' => $round->id, 'rule_set_id' => $ruleSet->id]);
|
||||
|
||||
$band = $this->createBand();
|
||||
$single = $this->createCategory(['name' => 'SINGLE']);
|
||||
$multi = $this->createCategory(['name' => 'MULTI']);
|
||||
|
||||
$logSingle = $this->createLog(['round_id' => $round->id]);
|
||||
$logMulti = $this->createLog(['round_id' => $round->id]);
|
||||
|
||||
$resSingle = $this->createLogResult([
|
||||
'evaluation_run_id' => $run->id,
|
||||
'log_id' => $logSingle->id,
|
||||
'band_id' => $band->id,
|
||||
'category_id' => $single->id,
|
||||
'official_score' => 200,
|
||||
'valid_qso_count' => 10,
|
||||
'status' => 'OK',
|
||||
'sixhr_category' => true,
|
||||
]);
|
||||
$resMulti = $this->createLogResult([
|
||||
'evaluation_run_id' => $run->id,
|
||||
'log_id' => $logMulti->id,
|
||||
'band_id' => $band->id,
|
||||
'category_id' => $multi->id,
|
||||
'official_score' => 150,
|
||||
'valid_qso_count' => 8,
|
||||
'status' => 'OK',
|
||||
'sixhr_category' => true,
|
||||
]);
|
||||
|
||||
(new RecalculateOfficialRanksJob($run->id))->handle();
|
||||
|
||||
$resSingle->refresh();
|
||||
$resMulti->refresh();
|
||||
|
||||
$this->assertSame(1, $resSingle->rank_overall);
|
||||
$this->assertSame(2, $resMulti->rank_overall);
|
||||
$this->assertSame('ALL', $resSingle->sixhr_ranking_bucket);
|
||||
$this->assertSame('ALL', $resMulti->sixhr_ranking_bucket);
|
||||
}
|
||||
|
||||
public function test_crk_sixhr_keeps_single_and_multi_separate(): void
|
||||
{
|
||||
$ruleSet = $this->createRuleSet(['sixhr_ranking_mode' => 'CRK']);
|
||||
$round = $this->createRound();
|
||||
$run = $this->createEvaluationRun(['round_id' => $round->id, 'rule_set_id' => $ruleSet->id]);
|
||||
|
||||
$band = $this->createBand();
|
||||
$single = $this->createCategory(['name' => 'SINGLE']);
|
||||
$multi = $this->createCategory(['name' => 'MULTI']);
|
||||
|
||||
$logSingle = $this->createLog(['round_id' => $round->id]);
|
||||
$logMulti = $this->createLog(['round_id' => $round->id]);
|
||||
|
||||
$resSingle = $this->createLogResult([
|
||||
'evaluation_run_id' => $run->id,
|
||||
'log_id' => $logSingle->id,
|
||||
'band_id' => $band->id,
|
||||
'category_id' => $single->id,
|
||||
'official_score' => 200,
|
||||
'valid_qso_count' => 10,
|
||||
'status' => 'OK',
|
||||
'sixhr_category' => true,
|
||||
]);
|
||||
$resMulti = $this->createLogResult([
|
||||
'evaluation_run_id' => $run->id,
|
||||
'log_id' => $logMulti->id,
|
||||
'band_id' => $band->id,
|
||||
'category_id' => $multi->id,
|
||||
'official_score' => 150,
|
||||
'valid_qso_count' => 8,
|
||||
'status' => 'OK',
|
||||
'sixhr_category' => true,
|
||||
]);
|
||||
|
||||
(new RecalculateOfficialRanksJob($run->id))->handle();
|
||||
|
||||
$resSingle->refresh();
|
||||
$resMulti->refresh();
|
||||
|
||||
$this->assertSame(1, $resSingle->rank_overall);
|
||||
$this->assertSame(1, $resMulti->rank_overall);
|
||||
$this->assertSame('SINGLE', $resSingle->sixhr_ranking_bucket);
|
||||
$this->assertSame('MULTI', $resMulti->sixhr_ranking_bucket);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user