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.
50 lines
1.4 KiB
50 lines
1.4 KiB
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class GateMultilingualSuccessTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/** @test */
|
|
public function test_visit_not_found_message_in_chinese()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'zh_CN'
|
|
])->get('/api/gate/visits/use-code', [
|
|
'type' => '1',
|
|
'admin_id' => '1',
|
|
'code' => 'nonexistent_code'
|
|
]);
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是中文错误消息
|
|
$this->assertEquals('拜访记录不存在', $data['errmsg']);
|
|
$this->assertEquals(10002, $data['errcode']); // ERROR_BUSINESS
|
|
}
|
|
|
|
/** @test */
|
|
public function test_visit_not_found_message_in_english()
|
|
{
|
|
$response = $this->withHeaders([
|
|
'Accept-Language' => 'en'
|
|
])->get('/api/gate/visits/use-code', [
|
|
'type' => '1',
|
|
'admin_id' => '1',
|
|
'code' => 'nonexistent_code'
|
|
]);
|
|
|
|
$response->assertStatus(200);
|
|
$data = $response->json();
|
|
|
|
// 验证返回的是英文错误消息
|
|
$this->assertEquals('Visit record not found', $data['errmsg']);
|
|
$this->assertEquals(10002, $data['errcode']); // ERROR_BUSINESS
|
|
}
|
|
}
|