-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathGrantProductToUserActionTest.php
More file actions
45 lines (36 loc) · 1.21 KB
/
Copy pathGrantProductToUserActionTest.php
File metadata and controls
45 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Tests\Feature\Filament;
use App\Filament\Resources\ProductResource\Pages\ListProducts;
use App\Models\Product;
use App\Models\User;
use Filament\Actions\Testing\TestAction;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class GrantProductToUserActionTest extends TestCase
{
use RefreshDatabase;
private User $admin;
protected function setUp(): void
{
parent::setUp();
$this->admin = User::factory()->create(['email' => 'admin@test.com']);
config(['filament.users' => ['admin@test.com']]);
}
public function test_grant_to_user_action_can_be_called_with_user_id(): void
{
$product = Product::factory()->active()->create();
$recipient = User::factory()->create();
Livewire::actingAs($this->admin)
->test(ListProducts::class)
->callAction(
TestAction::make('grantToUser')->table($product),
data: ['user_id' => $recipient->id],
)
->assertHasNoFormErrors();
$this->assertDatabaseHas('product_licenses', [
'user_id' => $recipient->id,
'product_id' => $product->id,
]);
}
}