Files
2026-10-20 09:57:43 +01:00

57 lines
2.2 KiB
PHP

<?php
namespace Modules\Stylist\Tests\Feature;
use Illuminate\Support\Facades\File;
use Tests\TestCase;
final class CommonApplicationViewsTest extends TestCase
{
public function test_common_theme_owns_application_authentication_and_settings_views(): void
{
foreach ([
'stylist-theme-common::components.layouts.app',
'stylist-theme-common::components.settings.layout',
'stylist-theme-common::partials.settings-heading',
'stylist-theme-common::livewire.settings.profile',
'stylist-theme-common::livewire.settings.appearance',
'stylist-theme-common::livewire.settings.security',
'stylist-theme-common::livewire.auth.login',
'stylist-theme-common::livewire.auth.register',
] as $view) {
$this->assertTrue(view()->exists($view), "Expected common view [{$view}] to exist.");
}
}
public function test_authentication_and_settings_views_are_not_duplicated(): void
{
$this->assertDirectoryDoesNotExist(resource_path('views'));
$this->assertDirectoryDoesNotExist(resource_path('themes/admin/views/livewire'));
$this->assertDirectoryDoesNotExist(resource_path('themes/welcome/views/livewire'));
$commonViews = resource_path('themes/common/views');
foreach ([
'livewire/auth/login.blade.php',
'livewire/auth/register.blade.php',
'livewire/auth/forgot-password.blade.php',
'livewire/auth/reset-password.blade.php',
'livewire/settings/profile.blade.php',
'livewire/settings/appearance.blade.php',
'livewire/settings/security.blade.php',
] as $relativePath) {
$matches = collect(File::allFiles(resource_path('themes')))
->filter(fn ($file) => str_ends_with(
str_replace('\\', '/', $file->getPathname()),
'/views/'.$relativePath
));
$this->assertCount(1, $matches, "Expected one authoritative view for [{$relativePath}].");
$this->assertStringStartsWith(
str_replace('\\', '/', $commonViews),
str_replace('\\', '/', $matches->first()->getPathname())
);
}
}
}