Skip to content

Commit af20160

Browse files
committed
Loader must create array structures as routes are not available yet
This is essentially no-op now so we may not need it
1 parent 8142e7f commit af20160

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

packages/framework/src/Foundation/Internal/LoadYamlConfiguration.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Throwable;
88
use Illuminate\Support\Arr;
9+
use Hyde\Facades\Navigation;
910
use Hyde\Foundation\Application;
1011
use Illuminate\Config\Repository;
1112
use Hyde\Framework\Features\Navigation\NavigationItem;
@@ -88,8 +89,8 @@ protected function parseAuthors(array $authors): array
8889
*/
8990
protected function parseNavigationItems(array $items): array
9091
{
91-
return Arr::map($items, function (array $item): NavigationItem {
92-
return NavigationItem::create($item['destination'], $item['label'], $item['priority']);
92+
return Arr::map($items, function (array $item): array {
93+
return Navigation::item($item['destination'], $item['label'], $item['priority']);
9394
});
9495
}
9596
}

packages/framework/tests/Feature/YamlConfigurationFeatureTest.php

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Illuminate\Support\Env;
99
use Hyde\Framework\Features\Navigation\NavigationItem;
1010
use Hyde\Framework\Features\Blogging\Models\PostAuthor;
11+
use Hyde\Framework\Features\Navigation\MainNavigationMenu;
1112
use Hyde\Framework\Exceptions\InvalidConfigurationException;
13+
use Hyde\Framework\Features\Navigation\NavigationMenuGenerator;
1214

1315
/**
1416
* Test the Yaml configuration feature.
@@ -476,22 +478,45 @@ public function testCanSetCustomNavigationItemsInTheYamlConfig()
476478

477479
$this->runBootstrappers();
478480

479-
$navigationItems = config('hyde.navigation.custom');
481+
$configItems = config('hyde.navigation.custom');
480482

481-
$this->assertCount(3, $navigationItems);
483+
$this->assertSame([
484+
[
485+
'destination' => 'https://example.com',
486+
'label' => 'Example',
487+
'priority' => 100,
488+
], [
489+
'destination' => 'about',
490+
'label' => 'About Us',
491+
'priority' => 200,
492+
], [
493+
'destination' => 'contact',
494+
'label' => 'Contact',
495+
'priority' => 300,
496+
],
497+
], $configItems);
498+
499+
/** @var NavigationItem[] $navigationItems */
500+
$navigationItems = NavigationMenuGenerator::handle(MainNavigationMenu::class)->getItems()->all();
501+
502+
$this->assertCount(4, $navigationItems);
482503
$this->assertContainsOnlyInstancesOf(NavigationItem::class, $navigationItems);
483504

484-
$this->assertSame('https://example.com', $navigationItems[0]->destination);
485-
$this->assertSame('Example', $navigationItems[0]->label);
486-
$this->assertSame(100, $navigationItems[0]->priority);
505+
$this->assertSame('index.html', $navigationItems[0]->getLink());
506+
$this->assertSame('Home', $navigationItems[0]->getLabel());
507+
$this->assertSame(0, $navigationItems[0]->getPriority());
508+
509+
$this->assertSame('https://example.com', $navigationItems[1]->getLink());
510+
$this->assertSame('Example', $navigationItems[1]->getLabel());
511+
$this->assertSame(100, $navigationItems[1]->getPriority());
487512

488-
$this->assertSame('about', $navigationItems[1]->destination);
489-
$this->assertSame('About Us', $navigationItems[1]->label);
490-
$this->assertSame(200, $navigationItems[1]->priority);
513+
$this->assertSame('about', $navigationItems[2]->getLink());
514+
$this->assertSame('About Us', $navigationItems[2]->getLabel());
515+
$this->assertSame(200, $navigationItems[2]->getPriority());
491516

492-
$this->assertSame('contact', $navigationItems[2]->destination);
493-
$this->assertSame('Contact', $navigationItems[2]->label);
494-
$this->assertSame(300, $navigationItems[2]->priority);
517+
$this->assertSame('contact', $navigationItems[3]->getLink());
518+
$this->assertSame('Contact', $navigationItems[3]->getLabel());
519+
$this->assertSame(300, $navigationItems[3]->getPriority());
495520
}
496521

497522
protected function runBootstrappers(?array $withMergedConfig = null): void

0 commit comments

Comments
 (0)