Skip to content

Commit

Permalink
Test new public find() method as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Oct 25, 2023
1 parent dd00e79 commit 8ef2e15
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/CP/Navigation/NavTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,35 @@ public function it_can_create_a_nav_item_with_a_custom_svg_icon()
}

/** @test */
public function it_can_get_and_modify_an_existing_item()
public function it_can_find_and_modify_an_existing_item()
{
$this->actingAs(tap(User::make()->makeSuper())->save());

Nav::droids('WAC-47')
->url('/pit-droid')
->icon('<svg>...</svg>');

Nav::find('Droids', 'WAC-47')
->url('/d-squad');

$item = $this->build()->get('Droids')->first();

$this->assertEquals('Droids', $item->section());
$this->assertEquals('WAC-47', $item->display());
$this->assertEquals('<svg>...</svg>', $item->icon());
$this->assertEquals('http://localhost/d-squad', $item->url());
}

/** @test */
public function it_can_find_and_modify_an_existing_item_using_magic_constructor()
{
$this->actingAs(tap(User::make()->makeSuper())->save());

Nav::droids('WAC-47')
->url('/pit-droid')
->icon('<svg>...</svg>');

// Callign the same constructor does a `findOrCreate()` under the hood...
Nav::droids('WAC-47')
->url('/d-squad');

Expand Down

0 comments on commit 8ef2e15

Please sign in to comment.