- 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
102 lines
3.3 KiB
PHP
102 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Application\Admin\ValueObjects;
|
|
|
|
use App\Application\Admin\ValueObjects\NavigationItem;
|
|
use App\Application\Admin\ValueObjects\NavigationMenu;
|
|
use App\Application\Admin\ValueObjects\NavigationSection;
|
|
|
|
describe('NavigationMenu Value Object', function () {
|
|
it('can be created with sections', function () {
|
|
$section = new NavigationSection('System', [
|
|
new NavigationItem('Dashboard', '/admin'),
|
|
]);
|
|
|
|
$menu = new NavigationMenu([$section]);
|
|
|
|
expect($menu->sections)->toHaveCount(1);
|
|
expect($menu->sections[0])->toBe($section);
|
|
});
|
|
|
|
it('can be created from array', function () {
|
|
$data = [
|
|
[
|
|
'section' => 'System',
|
|
'items' => [
|
|
['name' => 'Dashboard', 'url' => '/admin'],
|
|
['name' => 'Users', 'url' => '/admin/users'],
|
|
],
|
|
'icon' => 'server',
|
|
],
|
|
[
|
|
'section' => 'Content',
|
|
'items' => [
|
|
['name' => 'Pages', 'url' => '/admin/pages'],
|
|
],
|
|
],
|
|
];
|
|
|
|
$menu = NavigationMenu::fromArray($data);
|
|
|
|
expect($menu->sections)->toHaveCount(2);
|
|
expect($menu->sections[0]->name)->toBe('System');
|
|
expect($menu->sections[0]->icon)->toBe('server');
|
|
expect($menu->sections[0]->items)->toHaveCount(2);
|
|
expect($menu->sections[1]->name)->toBe('Content');
|
|
expect($menu->sections[1]->items)->toHaveCount(1);
|
|
});
|
|
|
|
it('converts to array correctly', function () {
|
|
$menu = new NavigationMenu([
|
|
new NavigationSection('System', [
|
|
new NavigationItem('Dashboard', '/admin', 'dashboard-icon'),
|
|
], 'server'),
|
|
]);
|
|
|
|
$array = $menu->toArray();
|
|
|
|
expect($array)->toHaveCount(1);
|
|
expect($array[0]['section'])->toBe('System');
|
|
expect($array[0]['icon'])->toBe('server');
|
|
expect($array[0]['items'])->toHaveCount(1);
|
|
expect($array[0]['items'][0]['name'])->toBe('Dashboard');
|
|
expect($array[0]['items'][0]['url'])->toBe('/admin');
|
|
expect($array[0]['items'][0]['icon'])->toBe('dashboard-icon');
|
|
});
|
|
|
|
it('can add sections immutably', function () {
|
|
$originalMenu = new NavigationMenu([]);
|
|
$newSection = new NavigationSection('New Section', []);
|
|
|
|
$newMenu = $originalMenu->addSection($newSection);
|
|
|
|
expect($originalMenu->sections)->toHaveCount(0);
|
|
expect($newMenu->sections)->toHaveCount(1);
|
|
expect($newMenu->sections[0])->toBe($newSection);
|
|
});
|
|
|
|
it('can find sections by name', function () {
|
|
$systemSection = new NavigationSection('System', []);
|
|
$contentSection = new NavigationSection('Content', []);
|
|
$menu = new NavigationMenu([$systemSection, $contentSection]);
|
|
|
|
$found = $menu->findSectionByName('System');
|
|
$notFound = $menu->findSectionByName('NonExistent');
|
|
|
|
expect($found)->toBe($systemSection);
|
|
expect($notFound)->toBeNull();
|
|
});
|
|
|
|
it('handles empty menu correctly', function () {
|
|
$menu = new NavigationMenu([]);
|
|
|
|
expect($menu->sections)->toHaveCount(0);
|
|
expect($menu->findSectionByName('Any'))->toBeNull();
|
|
|
|
$array = $menu->toArray();
|
|
expect($array)->toHaveCount(0);
|
|
});
|
|
});
|