From b3abed28799da4667aa9eae76155a0c36fcea2f7 Mon Sep 17 00:00:00 2001 From: Chris Morrell Date: Fri, 6 Jan 2023 12:49:48 -0500 Subject: [PATCH] Add test for hyphenated names --- tests/ResourceRoutesTest.php | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/ResourceRoutesTest.php b/tests/ResourceRoutesTest.php index 07f547e..3cf1c0c 100644 --- a/tests/ResourceRoutesTest.php +++ b/tests/ResourceRoutesTest.php @@ -176,6 +176,46 @@ public function test_custom_names(bool $cache): void ); } + /** @dataProvider cachingProvider */ + public function test_hyphenated_names(bool $cache): void + { + Route::middleware(SubstituteBindings::class) + ->group(function() { + Route::resource('jazzy-dancers', ResourceRoutesTestJazzyDancerController::class) + ->breadcrumbs(fn(ResourceBreadcrumbs $breadcrumbs) => $breadcrumbs + ->index('Jazzy Dancers') + ->create('New Dancer') + ->show(fn(User $jazzy_dancer) => $jazzy_dancer->name) + ->edit('Edit')); + }); + + $this->setUpCache($cache); + + $this->get(route('jazzy-dancers.index')); + $this->assertActiveBreadcrumbs( + ['Jazzy Dancers', '/jazzy-dancers'], + ); + + $this->get(route('jazzy-dancers.create')); + $this->assertActiveBreadcrumbs( + ['Jazzy Dancers', '/jazzy-dancers'], + ['New Dancer', '/jazzy-dancers/create'], + ); + + $this->get(route('jazzy-dancers.show', $this->user)); + $this->assertActiveBreadcrumbs( + ['Jazzy Dancers', '/jazzy-dancers'], + [$this->user->name, route('jazzy-dancers.show', $this->user)], + ); + + $this->get(route('jazzy-dancers.edit', $this->user)); + $this->assertActiveBreadcrumbs( + ['Jazzy Dancers', '/jazzy-dancers'], + [$this->user->name, route('jazzy-dancers.show', $this->user)], + ['Edit', route('jazzy-dancers.edit', $this->user)], + ); + } + /** @dataProvider cachingProvider */ public function test_custom_parents(bool $cache): void {