Add test for importer
This commit is contained in:
parent
9793016603
commit
256e989ba1
2 changed files with 30 additions and 0 deletions
|
@ -296,6 +296,11 @@ class UserFactory extends Factory
|
||||||
return $this->appendPermission(['reports.view' => '1']);
|
return $this->appendPermission(['reports.view' => '1']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canImport()
|
||||||
|
{
|
||||||
|
return $this->appendPermission(['import' => '1']);
|
||||||
|
}
|
||||||
|
|
||||||
private function appendPermission(array $permission)
|
private function appendPermission(array $permission)
|
||||||
{
|
{
|
||||||
return $this->state(function ($currentState) use ($permission) {
|
return $this->state(function ($currentState) use ($permission) {
|
||||||
|
|
25
tests/Feature/Livewire/ImporterTest.php
Normal file
25
tests/Feature/Livewire/ImporterTest.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Livewire;
|
||||||
|
|
||||||
|
use App\Livewire\Importer;
|
||||||
|
use App\Models\User;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ImporterTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testRendersSuccessfully()
|
||||||
|
{
|
||||||
|
Livewire::actingAs(User::factory()->canImport()->create())
|
||||||
|
->test(Importer::class)
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRequiresPermission()
|
||||||
|
{
|
||||||
|
Livewire::actingAs(User::factory()->create())
|
||||||
|
->test(Importer::class)
|
||||||
|
->assertStatus(403);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue