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.
41 lines
1.1 KiB
41 lines
1.1 KiB
|
3 months ago
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Feature;
|
||
|
|
|
||
|
|
use App\Models\Application;
|
||
|
|
use App\Models\Competition;
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
use Laravel\Sanctum\Sanctum;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class ParticipantApplicationSaveTest extends TestCase
|
||
|
|
{
|
||
|
|
use RefreshDatabase;
|
||
|
|
|
||
|
|
public function test_participant_can_save_draft_via_post_save_endpoint(): void
|
||
|
|
{
|
||
|
|
$user = User::query()->create(['mobile' => '13800138088']);
|
||
|
|
$competition = Competition::query()->create([
|
||
|
|
'slug' => 'xxf',
|
||
|
|
'name' => '测试赛',
|
||
|
|
'published' => true,
|
||
|
|
]);
|
||
|
|
Application::query()->create([
|
||
|
|
'user_id' => $user->id,
|
||
|
|
'competition_id' => $competition->id,
|
||
|
|
'status' => 'draft',
|
||
|
|
]);
|
||
|
|
|
||
|
|
Sanctum::actingAs($user);
|
||
|
|
|
||
|
|
$this->postJson('/api/applications/current/save?competition_slug=xxf', [
|
||
|
|
'player_name' => '张三',
|
||
|
|
'project_name' => '测试项目',
|
||
|
|
])
|
||
|
|
->assertOk()
|
||
|
|
->assertJsonPath('player_name', '张三')
|
||
|
|
->assertJsonPath('project_name', '测试项目');
|
||
|
|
}
|
||
|
|
}
|