-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed polling because of direct attribute checks
- Loading branch information
Showing
6 changed files
with
79 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
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,41 @@ | ||
<?php | ||
|
||
namespace Rennokki\QueryCache\Test; | ||
|
||
use Illuminate\Support\Facades\Cache; | ||
use Livewire\Component; | ||
use Livewire\Livewire; | ||
use Rennokki\QueryCache\Test\Models\Post; | ||
|
||
class LivewireTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider strictModeContextProvider | ||
*/ | ||
public function test_livewire_component_poll_doesnt_break_when_callback_is_already_set() | ||
{ | ||
// See: https://github.com/renoki-co/laravel-eloquent-query-cache/issues/163 | ||
Livewire::component(PostComponent::class); | ||
|
||
$posts = factory(Post::class, 30)->create(); | ||
|
||
/** @var \Livewire\Testing\TestableLivewire $component */ | ||
Livewire::test(PostComponent::class, ['post' => $posts->first()]) | ||
->assertOk() | ||
->assertSee($posts[0]->name) | ||
->pretendWereSendingAComponentUpdateRequest( | ||
'callMethod', | ||
['id' => 'grwk', 'method' => '$refresh', 'params' => []], | ||
); | ||
} | ||
} | ||
|
||
class PostComponent extends Component | ||
{ | ||
public Post $post; | ||
|
||
public static function getName() | ||
{ | ||
return 'post'; | ||
} | ||
} |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
@livewireStyles | ||
</head> | ||
<body> | ||
<livewire:post :post="$post"> | ||
@livewireScripts | ||
</body> | ||
</html> |
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,4 @@ | ||
<div wire:poll> | ||
<p>Title: {{ $post->name }}</p> | ||
<p>Time: <b>{{ now() }}</b></p> | ||
</div> |