|
6 | 6 |
|
7 | 7 | use Hyde\Testing\TestCase; |
8 | 8 | use Illuminate\Support\Env; |
| 9 | +use Hyde\Framework\Features\Navigation\NavigationItem; |
9 | 10 | use Hyde\Framework\Features\Blogging\Models\PostAuthor; |
10 | 11 | use Hyde\Framework\Exceptions\InvalidConfigurationException; |
11 | 12 |
|
@@ -456,6 +457,43 @@ public function testTypeErrorsInAuthorsYamlConfigAreRethrownMoreHelpfully() |
456 | 457 | unlink('hyde.yml'); |
457 | 458 | } |
458 | 459 |
|
| 460 | + public function testCanSetCustomNavigationItemsInTheYamlConfig() |
| 461 | + { |
| 462 | + $this->file('hyde.yml', <<<'YAML' |
| 463 | + hyde: |
| 464 | + navigation: |
| 465 | + custom: |
| 466 | + - destination: 'https://example.com' |
| 467 | + label: 'Example' |
| 468 | + priority: 100 |
| 469 | + - destination: 'about' |
| 470 | + label: 'About Us' |
| 471 | + priority: 200 |
| 472 | + - destination: 'contact' |
| 473 | + label: 'Contact' |
| 474 | + priority: 300 |
| 475 | + YAML); |
| 476 | + |
| 477 | + $this->runBootstrappers(); |
| 478 | + |
| 479 | + $navigationItems = config('hyde.navigation.custom'); |
| 480 | + |
| 481 | + $this->assertCount(3, $navigationItems); |
| 482 | + $this->assertContainsOnlyInstancesOf(NavigationItem::class, $navigationItems); |
| 483 | + |
| 484 | + $this->assertSame('https://example.com', $navigationItems[0]->destination); |
| 485 | + $this->assertSame('Example', $navigationItems[0]->label); |
| 486 | + $this->assertSame(100, $navigationItems[0]->priority); |
| 487 | + |
| 488 | + $this->assertSame('about', $navigationItems[1]->destination); |
| 489 | + $this->assertSame('About Us', $navigationItems[1]->label); |
| 490 | + $this->assertSame(200, $navigationItems[1]->priority); |
| 491 | + |
| 492 | + $this->assertSame('contact', $navigationItems[2]->destination); |
| 493 | + $this->assertSame('Contact', $navigationItems[2]->label); |
| 494 | + $this->assertSame(300, $navigationItems[2]->priority); |
| 495 | + } |
| 496 | + |
459 | 497 | protected function runBootstrappers(?array $withMergedConfig = null): void |
460 | 498 | { |
461 | 499 | $this->refreshApplication(); |
|
0 commit comments