Skip to content

Commit

Permalink
Add test for nested group filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerkretzmar committed Aug 4, 2023
1 parent 3beb080 commit abe40e6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Unit/ZiggyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,29 @@ public function optional_params_inside_path()
// Both
$this->assertSame('http://ziggy.dev/test//products/1', route('products.show', ['id' => 1]));
}

/** @test */
public function filter_route_names_from_nested_groups()
{
app('router')->get('foo', $this->noop())->name('foo');
app('router')->name('foo.')->group(function () {
app('router')->get('foo/bar', $this->noop())->name('bar');
app('router')->name('bar.')->group(function () {
app('router')->get('foo/bar/baz', $this->noop())->name('baz');
});
});
app('router')->getRoutes()->refreshNameLookups();

config(['ziggy.except' => ['foo.bar.*']]);

$this->assertArrayHasKey('foo', (new Ziggy)->toArray()['routes']);
$this->assertArrayHasKey('foo.bar', (new Ziggy)->toArray()['routes']);
$this->assertArrayNotHasKey('foo.bar.baz', (new Ziggy)->toArray()['routes']);

config(['ziggy.except' => ['foo.*']]);

$this->assertArrayHasKey('foo', (new Ziggy)->toArray()['routes']);
$this->assertArrayNotHasKey('foo.bar', (new Ziggy)->toArray()['routes']);
$this->assertArrayNotHasKey('foo.bar.baz', (new Ziggy)->toArray()['routes']);
}
}

0 comments on commit abe40e6

Please sign in to comment.