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.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Feature;
|
|
|
|
|
|
|
|
|
|
use App\Models\AdminUser;
|
|
|
|
|
use App\Models\Competition;
|
|
|
|
|
use App\Models\FormSchemaDefinition;
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
|
use Laravel\Sanctum\Sanctum;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class SignupFormSchemaValidationTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
use RefreshDatabase;
|
|
|
|
|
|
|
|
|
|
public function test_admin_can_save_signup_schema_with_generic_scalar_field_key(): void
|
|
|
|
|
{
|
|
|
|
|
Sanctum::actingAs(AdminUser::query()->create([
|
|
|
|
|
'username' => 'schema_admin',
|
|
|
|
|
'password_hash' => 'unused',
|
|
|
|
|
'name' => '管理员',
|
|
|
|
|
'status' => 'active',
|
|
|
|
|
]));
|
|
|
|
|
|
|
|
|
|
$competition = Competition::query()->create([
|
|
|
|
|
'slug' => 'xxf',
|
|
|
|
|
'name' => '测试赛',
|
|
|
|
|
'published' => true,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->postJson("/api/v1/admin/competitions/{$competition->id}/form-schemas", [
|
|
|
|
|
'purpose' => FormSchemaDefinition::PURPOSE_SIGNUP,
|
|
|
|
|
'name' => '含自定义字段',
|
|
|
|
|
'schema_json' => [
|
|
|
|
|
[
|
|
|
|
|
'key' => 'field_x',
|
|
|
|
|
'type' => 'text',
|
|
|
|
|
'label' => '自定义字段',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'is_published' => false,
|
|
|
|
|
])->assertCreated()
|
|
|
|
|
->assertJsonPath('schema_json.0.key', 'field_x');
|
|
|
|
|
}
|
|
|
|
|
}
|