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.
108 lines
2.9 KiB
108 lines
2.9 KiB
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
class MobileMultilingualTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/** @test */
|
|
public function test_mobile_login_endpoint_supports_multilingual()
|
|
{
|
|
// 测试中文
|
|
$response = $this->getJson('/api/mobile/user/login', [
|
|
'Accept-Language' => 'zh-CN'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 400, 422]);
|
|
|
|
// 测试英文
|
|
$response = $this->getJson('/api/mobile/user/login', [
|
|
'Accept-Language' => 'en'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 400, 422]);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_mobile_config_endpoint_supports_multilingual()
|
|
{
|
|
// 测试中文
|
|
$response = $this->getJson('/api/mobile/user/config', [
|
|
'Accept-Language' => 'zh-CN'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 400, 422]);
|
|
|
|
// 测试英文
|
|
$response = $this->getJson('/api/mobile/user/config', [
|
|
'Accept-Language' => 'en'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 400, 422]);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_mobile_visit_area_endpoint_supports_multilingual()
|
|
{
|
|
// 测试中文
|
|
$response = $this->getJson('/api/mobile/visit/visit-area', [
|
|
'Accept-Language' => 'zh-CN'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 401]);
|
|
|
|
// 测试英文
|
|
$response = $this->getJson('/api/mobile/visit/visit-area', [
|
|
'Accept-Language' => 'en'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 401]);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_mobile_visit_time_endpoint_supports_multilingual()
|
|
{
|
|
// 测试中文
|
|
$response = $this->getJson('/api/mobile/visit/visit-time', [
|
|
'Accept-Language' => 'zh-CN'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 401]);
|
|
|
|
// 测试英文
|
|
$response = $this->getJson('/api/mobile/visit/visit-time', [
|
|
'Accept-Language' => 'en'
|
|
]);
|
|
|
|
$this->assertContains($response->status(), [200, 401]);
|
|
}
|
|
|
|
/** @test */
|
|
public function test_mobile_error_messages_are_localized()
|
|
{
|
|
// 测试中文错误消息
|
|
$response = $this->getJson('/api/mobile/user/login', [
|
|
'Accept-Language' => 'zh-CN'
|
|
]);
|
|
|
|
if ($response->status() === 422) {
|
|
$data = $response->json();
|
|
$this->assertIsArray($data);
|
|
}
|
|
|
|
// 测试英文错误消息
|
|
$response = $this->getJson('/api/mobile/user/login', [
|
|
'Accept-Language' => 'en'
|
|
]);
|
|
|
|
if ($response->status() === 422) {
|
|
$data = $response->json();
|
|
$this->assertIsArray($data);
|
|
}
|
|
}
|
|
}
|