create([ 'username' => 'schema_admin', 'password_hash' => 'unused', 'name' => '管理员', 'status' => 'active', ])); $competition = Competition::query()->create([ 'slug' => 'xxf', 'name' => '测试赛', 'published' => true, ]); $response = $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, ]); $response->assertStatus(422) ->assertJsonPath('errors.schema_json.0', fn ($msg) => is_string($msg) && str_contains($msg, 'field_x')); } }