cms/tests/Feature/PublicPageTest.php

66 lines
1.9 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Tests\Feature;
use App\Models\Page;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PublicPageTest extends TestCase
{
use RefreshDatabase;
public function test_it_renders_homepage(): void
{
$page = Page::create([
'title' => 'Home',
'slug' => 'home',
'content' => [['type' => 'text', 'data' => ['text' => 'Welcome home']]],
'cached_html' => '<div>Welcome home</div>',
'is_published' => true,
'user_id' => User::factory()->create()->id,
]);
$response = $this->get('/');
$response->assertStatus(200);
$response->assertSee('Welcome home');
$response->assertSee('theme-icehouse'); // Verify Icehouse theme is used
}
public function test_it_renders_dynamic_page(): void
{
$page = Page::create([
'title' => 'About Us',
'slug' => 'about-us',
'content' => [['type' => 'text', 'data' => ['text' => 'We are SiteWeaver']]],
'cached_html' => '<div>We are SiteWeaver</div>',
'is_published' => true,
'user_id' => User::factory()->create()->id,
]);
$response = $this->get('/about-us');
$response->assertStatus(200);
$response->assertSee('We are SiteWeaver');
$response->assertSee('About Us');
}
public function test_it_returns_404_for_non_existent_page(): void
{
$response = $this->get('/non-existent');
$response->assertStatus(404);
}
public function test_it_serves_theme_assets(): void
{
$response = $this->get('/themes/icehouse/assets/css/style.css');
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'text/css; charset=utf-8');
$response->assertSee('theme-icehouse');
}
}