Certified/tests/Feature/LocaleTest.php
Joël van de Wouw ac340d125c
Some checks failed
linter / quality (push) Failing after 13s
tests / ci (8.3) (push) Failing after 2s
tests / ci (8.4) (push) Failing after 2s
tests / ci (8.5) (push) Failing after 3s
Initial commit
Certificate manager built on Laravel 13, Livewire 4, and Flux.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 14:44:58 +02:00

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');
});