cms/tests/Feature/ThemeIncludeTest.php

60 lines
1.5 KiB
PHP
Raw Normal View History

<?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');
}
}