feat(KAN-16): add English localization foundation
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LocalizationTest extends TestCase
|
||||
{
|
||||
public function test_frontend_localization_behaviour(): void
|
||||
{
|
||||
$process = new Process(['node', 'tests/Fixtures/localization.mjs'], base_path());
|
||||
$process->setTimeout(60);
|
||||
$process->run();
|
||||
|
||||
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||
$this->assertStringContainsString('Localization behavior checks passed.', $process->getOutput());
|
||||
}
|
||||
|
||||
public function test_initial_page_shares_the_application_locale_and_time_zone(): void
|
||||
{
|
||||
config(['app.timezone' => 'Europe/Berlin']);
|
||||
|
||||
$this->withHeader('Accept-Language', 'de-DE')->get(route('home'))
|
||||
->assertOk()
|
||||
->assertSee('lang="en"', false)
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->where('localization.locale', 'en')
|
||||
->where('localization.timeZone', 'Europe/Berlin'));
|
||||
}
|
||||
|
||||
public function test_server_validation_remains_english(): void
|
||||
{
|
||||
$this->assertSame('en', config('app.locale'));
|
||||
$this->assertSame('en', config('app.fallback_locale'));
|
||||
|
||||
$validator = Validator::make(['email' => 'invalid'], [
|
||||
'title' => ['required'],
|
||||
'email' => ['email'],
|
||||
]);
|
||||
|
||||
$this->assertSame('The title field is required.', $validator->errors()->first('title'));
|
||||
$this->assertSame('The email field must be a valid email address.', $validator->errors()->first('email'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user