- Move 12 markdown files from root to docs/ subdirectories - Organize documentation by category: • docs/troubleshooting/ (1 file) - Technical troubleshooting guides • docs/deployment/ (4 files) - Deployment and security documentation • docs/guides/ (3 files) - Feature-specific guides • docs/planning/ (4 files) - Planning and improvement proposals Root directory cleanup: - Reduced from 16 to 4 markdown files in root - Only essential project files remain: • CLAUDE.md (AI instructions) • README.md (Main project readme) • CLEANUP_PLAN.md (Current cleanup plan) • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements) This improves: ✅ Documentation discoverability ✅ Logical organization by purpose ✅ Clean root directory ✅ Better maintainability
119 lines
4.1 KiB
PHP
119 lines
4.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Application\Admin\ValueObjects;
|
|
|
|
use App\Application\Admin\ValueObjects\AdminLayoutData;
|
|
use App\Application\Admin\ValueObjects\Breadcrumb;
|
|
use App\Application\Admin\ValueObjects\BreadcrumbCollection;
|
|
use App\Application\Admin\ValueObjects\NavigationItem;
|
|
use App\Application\Admin\ValueObjects\NavigationMenu;
|
|
use App\Application\Admin\ValueObjects\NavigationSection;
|
|
|
|
describe('AdminLayoutData Value Object', function () {
|
|
it('can be created with all required parameters', function () {
|
|
$navigationMenu = new NavigationMenu([]);
|
|
$breadcrumbs = new BreadcrumbCollection([]);
|
|
|
|
$layoutData = new AdminLayoutData(
|
|
title: 'Test Page',
|
|
navigationMenu: $navigationMenu,
|
|
breadcrumbs: $breadcrumbs,
|
|
currentPath: '/admin/test'
|
|
);
|
|
|
|
expect($layoutData->title)->toBe('Test Page');
|
|
expect($layoutData->currentPath)->toBe('/admin/test');
|
|
expect($layoutData->navigationMenu)->toBe($navigationMenu);
|
|
expect($layoutData->breadcrumbs)->toBe($breadcrumbs);
|
|
});
|
|
|
|
it('can be created from array', function () {
|
|
$data = [
|
|
'title' => 'Dashboard',
|
|
'current_path' => '/admin/dashboard',
|
|
'navigation_menu' => [
|
|
[
|
|
'section' => 'System',
|
|
'items' => [
|
|
['name' => 'Dashboard', 'url' => '/admin'],
|
|
['name' => 'Users', 'url' => '/admin/users'],
|
|
],
|
|
],
|
|
],
|
|
'breadcrumbs_data' => [
|
|
['name' => 'Admin', 'url' => '/admin'],
|
|
['name' => 'Dashboard', 'url' => '/admin/dashboard'],
|
|
],
|
|
];
|
|
|
|
$layoutData = AdminLayoutData::fromArray($data);
|
|
|
|
expect($layoutData->title)->toBe('Dashboard');
|
|
expect($layoutData->currentPath)->toBe('/admin/dashboard');
|
|
expect($layoutData->navigationMenu->sections)->toHaveCount(1);
|
|
expect($layoutData->breadcrumbs->breadcrumbs)->toHaveCount(2);
|
|
});
|
|
|
|
it('converts to array correctly', function () {
|
|
$navigationMenu = new NavigationMenu([
|
|
new NavigationSection('System', [
|
|
new NavigationItem('Dashboard', '/admin'),
|
|
]),
|
|
]);
|
|
|
|
$breadcrumbs = new BreadcrumbCollection([
|
|
new Breadcrumb('Admin', '/admin'),
|
|
]);
|
|
|
|
$layoutData = new AdminLayoutData(
|
|
title: 'Test Page',
|
|
navigationMenu: $navigationMenu,
|
|
breadcrumbs: $breadcrumbs,
|
|
currentPath: '/admin/test'
|
|
);
|
|
|
|
$array = $layoutData->toArray();
|
|
|
|
expect($array['title'])->toBe('Test Page');
|
|
expect($array['page_title'])->toBe('Test Page');
|
|
expect($array['current_path'])->toBe('/admin/test');
|
|
expect($array['navigation_menu'])->toBeArray();
|
|
expect($array['breadcrumbs_data'])->toBeArray();
|
|
});
|
|
|
|
it('supports immutable transformations', function () {
|
|
$originalData = new AdminLayoutData(
|
|
title: 'Original',
|
|
navigationMenu: new NavigationMenu([]),
|
|
breadcrumbs: new BreadcrumbCollection([]),
|
|
currentPath: '/admin'
|
|
);
|
|
|
|
$newData = $originalData->withTitle('New Title');
|
|
|
|
expect($originalData->title)->toBe('Original');
|
|
expect($newData->title)->toBe('New Title');
|
|
expect($newData)->not->toBe($originalData);
|
|
});
|
|
|
|
it('handles optional parameters correctly', function () {
|
|
$layoutData = new AdminLayoutData(
|
|
title: 'Test',
|
|
navigationMenu: new NavigationMenu([]),
|
|
breadcrumbs: new BreadcrumbCollection([]),
|
|
currentPath: '/admin',
|
|
metaDescription: 'Test description',
|
|
pageClass: 'admin-page'
|
|
);
|
|
|
|
expect($layoutData->metaDescription)->toBe('Test description');
|
|
expect($layoutData->pageClass)->toBe('admin-page');
|
|
|
|
$array = $layoutData->toArray();
|
|
expect($array['meta_description'])->toBe('Test description');
|
|
expect($array['page_class'])->toBe('admin-page');
|
|
});
|
|
});
|