Skip to content

Commit 1b35793

Browse files
committed
Update constructor to use the same logic as the static create method
1 parent 3bcafeb commit 1b35793

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/framework/src/Framework/Features/Navigation/NavigationItem.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class NavigationItem implements Stringable
2323

2424
public function __construct(Route|string $destination, string $label, int $priority = NavigationMenu::DEFAULT)
2525
{
26-
$this->label = $label;
27-
$this->priority = $priority;
28-
$this->destination = $destination;
26+
[$this->destination, $this->label, $this->priority] = self::make($destination, $label, $priority);
2927
}
3028

3129
/**

packages/framework/tests/Unit/NavigationItemTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public function testPassingRouteInstanceToConstructorUsesRouteInstance()
5151
$this->assertEquals($route, (new NavigationItem($route, 'Home'))->getPage()->getRoute());
5252
}
5353

54-
public function testPassingRouteKeyToConstructorUsesDestinationAsLink()
54+
public function testPassingRouteKeyToConstructorUsesDestinationAsRoute()
5555
{
5656
$item = new NavigationItem('index', 'Home');
57-
$this->assertNull($item->getPage());
58-
$this->assertSame('index', $item->getLink());
57+
$this->assertSame(Routes::get('index')->getPage(), $item->getPage());
58+
$this->assertSame('index', $item->getPage()->getRouteKey());
59+
$this->assertSame('index.html', $item->getLink());
5960
}
6061

6162
public function testPassingUrlToConstructorSetsRouteToNull()

0 commit comments

Comments
 (0)