Skip to content

Commit

Permalink
Update constructor to use the same logic as the static create method
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Mar 26, 2024
1 parent 3bcafeb commit 1b35793
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class NavigationItem implements Stringable

public function __construct(Route|string $destination, string $label, int $priority = NavigationMenu::DEFAULT)
{
$this->label = $label;
$this->priority = $priority;
$this->destination = $destination;
[$this->destination, $this->label, $this->priority] = self::make($destination, $label, $priority);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions packages/framework/tests/Unit/NavigationItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ public function testPassingRouteInstanceToConstructorUsesRouteInstance()
$this->assertEquals($route, (new NavigationItem($route, 'Home'))->getPage()->getRoute());
}

public function testPassingRouteKeyToConstructorUsesDestinationAsLink()
public function testPassingRouteKeyToConstructorUsesDestinationAsRoute()
{
$item = new NavigationItem('index', 'Home');
$this->assertNull($item->getPage());
$this->assertSame('index', $item->getLink());
$this->assertSame(Routes::get('index')->getPage(), $item->getPage());
$this->assertSame('index', $item->getPage()->getRouteKey());
$this->assertSame('index.html', $item->getLink());
}

public function testPassingUrlToConstructorSetsRouteToNull()
Expand Down

0 comments on commit 1b35793

Please sign in to comment.