-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes model route binding with custom keys
- Loading branch information
1 parent
acd4d54
commit 517ca4e
Showing
3 changed files
with
55 additions
and
0 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 |
---|---|---|
|
@@ -835,6 +835,43 @@ public function render() | |
->assertOk(); | ||
}); | ||
|
||
it('test 200s model route binding on full page components', function (string $route, string $uri) { | ||
User::create([ | ||
'name' => 'taylor', | ||
'email' => '[email protected]', | ||
'password' => 'password', | ||
]); | ||
|
||
Volt::route('/users/'.$route, 'navigate.with-model-route-binding'); | ||
|
||
$this->get('/users/'.$uri) | ||
->assertStatus(200) | ||
->assertSee('Volt 1 using mount.'); | ||
})->with([ | ||
['{user}', '1'], | ||
['{user:id}', '1'], | ||
['{user:name}', 'taylor'], | ||
['{user:email}', '[email protected]'], | ||
]); | ||
|
||
it('test 404s model route binding on full page components', function (string $route, string $uri) { | ||
User::create([ | ||
'name' => 'taylor', | ||
'email' => '[email protected]', | ||
'password' => 'password', | ||
]); | ||
|
||
Volt::route('/users/'.$route, 'navigate.with-model-route-binding'); | ||
|
||
$this->get('/users/'.$uri) | ||
->assertStatus(404); | ||
})->with([ | ||
['{user}', '2'], | ||
['{user:id}', '2'], | ||
['{user:name}', 'nuno'], | ||
['{user:email}', '[email protected]'], | ||
]); | ||
|
||
test('user imports on bottom do not conflict', function () { | ||
User::create([ | ||
'name' => 'Taylor', | ||
|
17 changes: 17 additions & 0 deletions
17
tests/Feature/resources/views/functional-api/navigate/with-model-route-binding.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,17 @@ | ||
<?php | ||
use function Livewire\Volt\mount; | ||
use function Livewire\Volt\state; | ||
use Tests\Fixtures\User; | ||
state('user'); | ||
mount(fn (User $user) => $this->user = $user); | ||
?> | ||
|
||
<div> | ||
<div> | ||
Volt {{ $user->id }} using mount. | ||
</div> | ||
</div> |