Certificate manager built on Laravel 13, Livewire 4, and Flux. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
|
|
test('a guest can switch the language and it is kept in the session', function () {
|
|
$response = $this->get('/language/nl');
|
|
|
|
$response->assertRedirect();
|
|
expect(session('locale'))->toBe('nl');
|
|
});
|
|
|
|
test('switching to an unsupported locale is rejected', function () {
|
|
$this->get('/language/de')->assertNotFound();
|
|
|
|
expect(session('locale'))->toBeNull();
|
|
});
|
|
|
|
test('switching the language persists it on the authenticated user', function () {
|
|
$user = User::factory()->create(['locale' => 'en']);
|
|
$this->actingAs($user);
|
|
|
|
$this->get('/language/nl')->assertRedirect();
|
|
|
|
expect($user->refresh()->locale)->toBe('nl');
|
|
});
|
|
|
|
test("a guest's session locale is applied to the rendered page", function () {
|
|
$this->withSession(['locale' => 'nl']);
|
|
|
|
$this->get(route('login'))
|
|
->assertOk()
|
|
->assertSee('Inloggen')
|
|
->assertSee('Wachtwoord vergeten');
|
|
});
|
|
|
|
test("an authenticated user's saved locale is applied even without a session value", function () {
|
|
$user = User::factory()->create(['locale' => 'nl']);
|
|
$this->actingAs($user);
|
|
|
|
$this->get(route('dashboard'))
|
|
->assertOk()
|
|
->assertSee('Certificaten');
|
|
});
|
|
|
|
test('the default locale is english', function () {
|
|
$this->get(route('login'))
|
|
->assertOk()
|
|
->assertSee('Log in')
|
|
->assertDontSee('Inloggen');
|
|
});
|