54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use Tests\TestCase;
|
|
|
|
class SitePagesTest extends TestCase
|
|
{
|
|
/**
|
|
* @return array<string, array{string, string}>
|
|
*/
|
|
public static function pages(): array
|
|
{
|
|
return [
|
|
'home' => ['home', 'site/home'],
|
|
'about' => ['about', 'site/about'],
|
|
'services' => ['services', 'site/services'],
|
|
'clients' => ['clients', 'site/clients'],
|
|
'contact' => ['contact', 'site/contact'],
|
|
];
|
|
}
|
|
|
|
#[DataProvider('pages')]
|
|
public function test_public_page_renders_its_component(string $route, string $component)
|
|
{
|
|
$this->get(route($route))
|
|
->assertOk()
|
|
->assertInertia(fn (Assert $page) => $page->component($component));
|
|
}
|
|
|
|
public function test_site_defaults_to_indonesian()
|
|
{
|
|
$this->get(route('home'))
|
|
->assertInertia(fn (Assert $page) => $page->where('locale', 'id'));
|
|
}
|
|
|
|
public function test_locale_cookie_switches_the_site_to_english()
|
|
{
|
|
$this->withUnencryptedCookie('locale', 'en')
|
|
->get(route('home'))
|
|
->assertSee('<html lang="en"', false)
|
|
->assertInertia(fn (Assert $page) => $page->where('locale', 'en'));
|
|
}
|
|
|
|
public function test_unsupported_locale_cookie_falls_back_to_indonesian()
|
|
{
|
|
$this->withUnencryptedCookie('locale', 'fr')
|
|
->get(route('home'))
|
|
->assertInertia(fn (Assert $page) => $page->where('locale', 'id'));
|
|
}
|
|
}
|