cms/tests/Feature/Admin/ThemeManagementTest.php

59 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Tests\Feature\Admin;
use App\Models\User;
use App\Models\Setting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ThemeManagementTest extends TestCase
{
use RefreshDatabase;
protected User $admin;
protected function setUp(): void
{
parent::setUp();
$this->admin = User::factory()->create();
$this->admin->roles()->create(['name' => 'Admin', 'slug' => 'admin']);
}
public function test_admin_can_view_themes_list()
{
$response = $this->actingAs($this->admin)
->get('/loom/themes');
$response->assertStatus(200);
$response->assertViewHas('themes');
$response->assertViewHas('activeTheme');
}
public function test_admin_can_activate_theme()
{
// Initial state
Setting::set('active_theme', 'icehouse', 'cms');
$response = $this->actingAs($this->admin)
->post('/loom/themes/activate', [
'theme' => 'royal'
]);
$response->assertStatus(200);
$response->assertJsonPath('active_theme', 'royal');
$this->assertEquals('royal', Setting::get('active_theme'));
}
public function test_cannot_activate_non_existent_theme()
{
$response = $this->actingAs($this->admin)
->postJson('/loom/themes/activate', [
'theme' => 'non-existent-theme'
]);
$response->assertStatus(404);
}
}