cms/tests/Feature/ThemeIncludeTest.php
Funky Waddle 37ed997989 feat(cms): initialize Laravel project structure and core CMS files
- Added standard Laravel directory structure and configuration.

- Included Svelte and Tailwind configuration for the admin interface.

- Added core PHPUnit and testing scripts.
2026-04-13 12:48:06 -05:00

60 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\User;
use App\Models\Page;
use App\Models\Setting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ThemeIncludeTest extends TestCase
{
use RefreshDatabase;
public function test_it_fails_to_include_navigation_without_namespace()
{
$user = User::factory()->create();
Setting::set('active_theme', 'bloody');
$page = Page::create([
'user_id' => $user->id,
'title' => 'Home',
'slug' => 'home',
'content' => [],
'is_published' => true,
]);
$layoutPath = base_path('themes/bloody/layout.blade.php');
$originalContent = file_get_contents($layoutPath);
try {
// Revert it to the broken state (no namespace)
file_put_contents($layoutPath, str_replace("themes::navigation", "navigation", $originalContent));
$this->get('/')
->assertStatus(500);
} finally {
file_put_contents($layoutPath, $originalContent);
}
}
public function test_it_succeeds_to_include_navigation_with_shortened_namespace()
{
$user = User::factory()->create();
Setting::set('active_theme', 'bloody');
$page = Page::create([
'user_id' => $user->id,
'title' => 'Home',
'slug' => 'home',
'content' => [],
'is_published' => true,
]);
$this->get('/')
->assertStatus(200)
->assertSee('Home');
}
}