Files
afriadirahman 8c6dad2a31
tests / ci (push) Canceled after 0s
Admin Panel
2026-09-29 14:57:37 +07:00

69 lines
2.0 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Inertia\Testing\AssertableInertia as Assert;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
class SitePagesTest extends TestCase
{
use RefreshDatabase;
/**
* @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_admin_login_page_renders()
{
$this->get(route('login'))
->assertOk()
->assertInertia(fn (Assert $page) => $page->component('auth/login'));
}
public function test_public_registration_is_disabled()
{
$this->get('/register')->assertNotFound();
}
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'));
}
}