cms/tests/Feature/ChildThemeTest.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

80 lines
2.3 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\User;
use App\Models\Page;
use App\Models\Setting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\File;
use Tests\TestCase;
class ChildThemeTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
// Ensure child theme directory exists
if (!File::exists(base_path('themes/bloody-child'))) {
File::makeDirectory(base_path('themes/bloody-child'));
}
File::put(base_path('themes/bloody-child/theme.md'), "title: Bloody Child\nparent: bloody");
}
protected function tearDown(): void
{
if (File::exists(base_path('themes/bloody-child'))) {
File::deleteDirectory(base_path('themes/bloody-child'));
}
parent::tearDown();
}
public function test_child_theme_can_use_parent_views_with_shortened_namespace()
{
$user = User::factory()->create();
Setting::set('active_theme', 'bloody-child');
Page::create([
'user_id' => $user->id,
'title' => 'Home',
'slug' => 'home',
'content' => [],
'is_published' => true,
]);
// When we access the home page, it should use themes::layout.
// themes::layout is NOT in bloody-child, but IS in bloody.
// It should fallback correctly.
$this->get('/')
->assertStatus(200)
->assertSee('Home');
}
public function test_child_theme_can_override_parent_views()
{
$user = User::factory()->create();
Setting::set('active_theme', 'bloody-child');
// Create an overridden navigation in the child theme
File::put(base_path('themes/bloody-child/navigation.blade.php'), '<nav>CHILD NAVIGATION</nav>');
Page::create([
'user_id' => $user->id,
'title' => 'Home',
'slug' => 'home',
'content' => [],
'is_published' => true,
]);
// It should use the child navigation instead of the parent one
$this->get('/')
->assertStatus(200)
->assertSee('CHILD NAVIGATION')
->assertDontSee('Blog') // Original navigation had Blog
->assertDontSee('Calendar');
}
}