You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

4 weeks ago
<?php
namespace Tests\Feature;
use App\Models\Competition;
use App\Models\CompetitionTrack;
use App\Support\DefaultTrackScoringSheets;
use Database\Seeders\CompetitionDefaultTracksSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class OtherTrackScoringSheetTest extends TestCase
{
use RefreshDatabase;
public function test_seeder_copies_materials_sheet_to_other_track(): void
{
$competition = Competition::query()->create([
'slug' => 'hsxt-other-track',
'name' => '首届沪苏协同新兴产业青年科创大赛',
'published' => true,
]);
$this->seed(CompetitionDefaultTracksSeeder::class);
$source = CompetitionTrack::query()
->where('competition_id', $competition->id)
->where('track_code', 'guang_xinpian')
->first();
$other = CompetitionTrack::query()
->where('competition_id', $competition->id)
->where('track_code', 'other')
->first();
$this->assertNotNull($source);
$this->assertNotNull($other);
$this->assertSame('其他', $other->title);
$this->assertSame('Other', $other->title_en);
$this->assertSame('', (string) $other->description);
$this->assertSame($source->scoring_sheet_json['items'] ?? null, $other->scoring_sheet_json['items'] ?? null);
$this->assertSame(
DefaultTrackScoringSheets::CONTEST_SHEET_PREFIX.'(其他赛道)',
$other->scoring_sheet_json['title'] ?? null,
);
$this->assertSame(
DefaultTrackScoringSheets::CONTEST_SHEET_PREFIX.'(材料与芯片赛道)',
$source->scoring_sheet_json['title'] ?? null,
);
}
}