-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds
request()->routeIs(...)
support (#93)
- Loading branch information
1 parent
3ebcf02
commit 6af158d
Showing
4 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Laravel\Folio\Folio; | ||
|
||
beforeEach(fn () => Folio::route(__DIR__.'/resources/views/another-set-of-pages')); | ||
|
||
it('dynamically updates folio is named route', function () { | ||
$response = $this->get(route('pens.index')); | ||
|
||
$response | ||
->assertSee('Is pens.index active: true.') | ||
->assertSee('Current route name: pens.index.') | ||
->assertSee('Has pens.index: false.') | ||
->assertSee('Is pens: true.'); | ||
}); | ||
|
||
it('resets folio is route name after handling request', function () { | ||
$this->get(route('pens.index')); | ||
|
||
expect(request()->route()->getName())->toBe('laravel-folio'); | ||
}); | ||
|
||
it('does not change the route name if there is no name', function () { | ||
$response = $this->get('pens/show'); | ||
|
||
$response | ||
->assertSee('Is pens.show active: false.') | ||
->assertSee('Current route name: laravel-folio.') | ||
->assertSee('Has pens.show: false.') | ||
->assertSee('Is pens/show: true.'); | ||
}); |
14 changes: 14 additions & 0 deletions
14
tests/Feature/resources/views/another-set-of-pages/pens/index.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
use function Laravel\Folio\name; | ||
name('pens.index'); ?> | ||
|
||
<x-app> | ||
<ul> | ||
<li>Is pens.index active: {{ request()->routeIs('pens.index') ? 'true' : 'false' }}.</li> | ||
<li>Current route name: {{ Route::currentRouteName() }}.</li> | ||
<li>Has pens.index: {{ Route::has('pens.index') ? 'true' : 'false' }}.</li> <!-- It's a know limitation... --> | ||
<li>Is pens: {{ request()->is('pens') ? 'true' : 'false' }}.</li> | ||
</ul> | ||
</x-app> |
8 changes: 8 additions & 0 deletions
8
tests/Feature/resources/views/another-set-of-pages/pens/show.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<x-app> | ||
<ul> | ||
<li>Is pens.show active: {{ request()->routeIs('pens.show') ? 'true' : 'false' }}.</li> | ||
<li>Current route name: {{ Route::currentRouteName() }}.</li> | ||
<li>Has pens.show: {{ Route::has('pens.show') ? 'true' : 'false' }}.</li> <!-- It's a know limitation... --> | ||
<li>Is pens/show: {{ request()->is('pens/show') ? 'true' : 'false' }}.</li> | ||
</ul> | ||
</x-app> |