Skip to content

Commit

Permalink
Update DropdownNavItem to support setting priority in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Oct 19, 2023
1 parent 888a907 commit 1915c81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class DropdownNavItem extends NavItem
public array $items;

/** @param array<NavItem> $items */
public function __construct(string $label, array $items)
public function __construct(string $label, array $items, int $priority = 999)
{
parent::__construct('', $label, 999);
parent::__construct('', $label, $priority);
$this->items = $items;
}

Expand Down
10 changes: 10 additions & 0 deletions packages/framework/tests/Unit/DropdownNavItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public function testConstruct()

$this->assertSame('foo', $item->label);
$this->assertSame([], $item->items);
$this->assertSame(999, $item->priority);
}

public function testConstructWithCustomPriority()
{
$item = new DropdownNavItem('foo', [], 500);

$this->assertSame('foo', $item->label);
$this->assertSame([], $item->items);
$this->assertSame(500, $item->priority);
}

public function testFromArray()
Expand Down

0 comments on commit 1915c81

Please sign in to comment.