- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?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);
|
|
}
|
|
}
|