-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for FailedJobResource and renamed to singular
- Loading branch information
Showing
6 changed files
with
77 additions
and
5 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
13 changes: 13 additions & 0 deletions
13
app/Filament/Resources/FailedJobResource/Pages/ViewFailedJobs.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\FailedJobResource\Pages; | ||
|
||
use App\Filament\Resources\FailedJobResource; | ||
use Filament\Resources\Pages\ViewRecord; | ||
|
||
class ViewFailedJobs extends ViewRecord | ||
{ | ||
protected static string $resource = FailedJobResource::class; | ||
} |
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
Binary file not shown.
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit\Filament; | ||
|
||
use App\Filament\Resources\FailedJobResource; | ||
use App\Filament\Resources\FailedJobResource\Pages\ViewFailedJobs; | ||
use App\Models\FailedJob; | ||
use App\Models\User; | ||
use Illuminate\Support\Facades\Config; | ||
use Livewire\Livewire; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
|
||
#[UsesClass(FailedJobResource::class)] | ||
class FailedJobResourceTest extends FilamentTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
Config::set('auth.super_admins', ['[email protected]']); | ||
$user = User::factory()->withPersonalOrganization()->create([ | ||
'email' => '[email protected]', | ||
]); | ||
|
||
$this->actingAs($user); | ||
} | ||
|
||
public function test_can_list_failed_jobs(): void | ||
{ | ||
// Arrange | ||
$failedJobs = FailedJob::factory()->createMany(5); | ||
|
||
// Act | ||
$response = Livewire::test(FailedJobResource\Pages\ListFailedJobs::class); | ||
|
||
// Assert | ||
$response->assertSuccessful(); | ||
$response->assertCanSeeTableRecords($failedJobs); | ||
} | ||
|
||
public function test_can_see_view_page_of_failed_job(): void | ||
{ | ||
// Arrange | ||
$failedJob = FailedJob::factory()->create(); | ||
|
||
// Act | ||
$response = Livewire::test(ViewFailedJobs::class, ['record' => $failedJob->getKey()]); | ||
|
||
// Assert | ||
$response->assertSuccessful(); | ||
} | ||
} |