-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.x] Fixes bottom script being included as template (#38)
* Fixes bottom conflicts * One more test * One more test
- Loading branch information
1 parent
d50867c
commit 9d6c455
Showing
5 changed files
with
406 additions
and
7 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
32 changes: 32 additions & 0 deletions
32
...__component_with_user_imports_blade_php______tests_Feature_resources_view___de_php__.snap
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,32 @@ | ||
<?php | ||
|
||
use Livewire\Volt\Actions; | ||
use Livewire\Volt\CompileContext; | ||
use Livewire\Volt\Contracts\Compiled; | ||
use Livewire\Volt\Component; | ||
|
||
new class extends Component implements Livewire\Volt\Contracts\FunctionalComponent | ||
{ | ||
public static CompileContext $__context; | ||
|
||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | ||
|
||
public $name; | ||
|
||
public $counter; | ||
|
||
public function mount($name = NULL) | ||
{ | ||
(new Actions\InitializeState)->execute(static::$__context, $this, get_defined_vars()); | ||
|
||
(new Actions\CallHook('mount'))->execute(static::$__context, $this, get_defined_vars()); | ||
} | ||
|
||
public function increment() | ||
{ | ||
$arguments = [static::$__context, $this, func_get_args()]; | ||
|
||
return (new Actions\CallMethod('increment'))->execute(...$arguments); | ||
} | ||
|
||
}; |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
use Livewire\Volt\Volt; | ||
use Pest\TestSuite; | ||
use Tests\Fixtures\GlobalTrait; | ||
use Tests\Fixtures\User; | ||
|
||
beforeEach(function () { | ||
View::setFinder(new FileViewFinder(app()['files'], [__DIR__.'/resources/views'])); | ||
|
@@ -789,3 +790,18 @@ public function render() | |
->assertSeeVolt('basic-component') | ||
->assertOk(); | ||
}); | ||
|
||
test('user imports on bottom do not conflict', function () { | ||
User::create([ | ||
'name' => 'Taylor', | ||
'email' => '[email protected]', | ||
'password' => 'password', | ||
]); | ||
|
||
Livewire::test('component-with-user-imports', ['name' => 'Taylor']) | ||
->assertSet('counter', 0) | ||
->call('increment') | ||
->call('increment') | ||
->call('increment') | ||
->assertSet('counter', 3); | ||
}); |
21 changes: 21 additions & 0 deletions
21
tests/Feature/resources/views/functional-api/component-with-user-imports.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,21 @@ | ||
<div> | ||
Hello {{ $name }} | ||
<br/> | ||
Counter: {{ $counter }} | ||
<br/> | ||
<button wire:click="increment"> | ||
Increment Counter | ||
</button> | ||
</div> | ||
|
||
<?php | ||
use Tests\Fixtures\User; | ||
use function Livewire\Volt\mount; | ||
use function Livewire\Volt\state; | ||
state(name: '', counter: 0); | ||
mount(fn ($name = null) => $this->name = $name ?? User::first()->name); | ||
$increment = fn () => $this->counter++; |
Oops, something went wrong.