-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make public component methods available in view (#2352)
* Make public component methods available in view * Remove unnecessary import
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
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,49 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use Livewire\Component; | ||
use Livewire\Livewire; | ||
|
||
class PublicMethodsAreAvailableInTheViewTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function public_methods_is_accessible_in_view_via_this() | ||
{ | ||
Livewire::test(PublicMethodsInViewWithoutThisStub::class) | ||
->assertSee('Your Name is Chris'); | ||
} | ||
|
||
/** @test */ | ||
public function public_methods_are_accessible_in_view_without_this() | ||
{ | ||
Livewire::test(PublicMethodsInViewWithoutThisStub::class) | ||
->assertSee('Your Name is Chris'); | ||
} | ||
} | ||
|
||
class PublicMethodsInViewWithThisStub extends Component | ||
{ | ||
public function render() | ||
{ | ||
return app('view')->make('call-name-with-this'); | ||
} | ||
|
||
public function name($name) | ||
{ | ||
return 'Your Name is '.$name; | ||
} | ||
} | ||
|
||
class PublicMethodsInViewWithoutThisStub extends Component | ||
{ | ||
public function render() | ||
{ | ||
return app('view')->make('call-name'); | ||
} | ||
|
||
public function name($name) | ||
{ | ||
return 'Your Name is '.$name; | ||
} | ||
} |
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 @@ | ||
<span>{{ $this->name('Chris') }}</span> |
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 @@ | ||
<span>{{ $name('Chris') }}</span> |