-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathGedcomResourceTest.php
More file actions
63 lines (49 loc) · 1.62 KB
/
GedcomResourceTest.php
File metadata and controls
63 lines (49 loc) · 1.62 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Tests\Feature\Filament\Resources;
use App\Filament\App\Resources\GedcomResource;
use App\Jobs\ExportGedCom;
use App\Models\Gedcom;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class GedcomResourceTest extends TestCase
{
use RefreshDatabase;
protected $user;
#[\Override]
protected function setUp(): void
{
parent::setUp();
Queue::fake();
$this->user = User::factory()->create();
}
public function test_resource_has_correct_model(): void
{
$this->assertEquals(Gedcom::class, GedcomResource::getModel());
}
public function test_resource_navigation_is_configured(): void
{
$this->assertNotEmpty(GedcomResource::getNavigationLabel());
$this->assertNotEmpty(GedcomResource::getNavigationIcon());
}
public function test_resource_has_pages_defined(): void
{
$pages = GedcomResource::getPages();
$this->assertArrayHasKey('index', $pages);
$this->assertArrayHasKey('create', $pages);
}
public function test_export_gedcom_dispatches_job_with_authenticated_user(): void
{
Auth::login($this->user);
GedcomResource::exportGedcom();
Queue::assertPushed(ExportGedCom::class, fn ($job): bool => $job->user->id === $this->user->id);
}
public function test_export_gedcom_does_not_dispatch_without_authenticated_user(): void
{
Auth::logout();
GedcomResource::exportGedcom();
Queue::assertNotPushed(ExportGedCom::class);
}
}