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.
74 lines
2.1 KiB
74 lines
2.1 KiB
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class GateMultilingualTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/** @test */
|
|
public function test_use_code_validation_messages_in_chinese()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'zh-CN'
|
|
])->get('/api/gate/visits/use-code');
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是错误信息,且包含中文验证消息
|
|
$this->assertStringContainsString('类型必填', $data['errmsg']);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_use_code_validation_messages_in_english()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'en'
|
|
])->get('/api/gate/visits/use-code');
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是错误信息,且包含英文验证消息
|
|
$this->assertStringContainsString('Type is required', $data['errmsg']);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_use_code_missing_code_or_idcard_in_chinese()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'zh-CN'
|
|
])->get('/api/gate/visits/use-code', [
|
|
'type' => '1',
|
|
'admin_id' => '1'
|
|
]);
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是错误信息,且包含中文消息
|
|
$this->assertStringContainsString('编号或身份证必填', $data['errmsg']);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_use_code_missing_code_or_idcard_in_english()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'en'
|
|
])->get('/api/gate/visits/use-code', [
|
|
'type' => '1',
|
|
'admin_id' => '1'
|
|
]);
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是错误信息,且包含英文消息
|
|
$this->assertStringContainsString('Code or ID card is required', $data['errmsg']);
|
|
}
|
|
}
|