mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Add test for importer
This commit is contained in:
parent
9793016603
commit
256e989ba1
|
@ -296,6 +296,11 @@ class UserFactory extends Factory
|
|||
return $this->appendPermission(['reports.view' => '1']);
|
||||
}
|
||||
|
||||
public function canImport()
|
||||
{
|
||||
return $this->appendPermission(['import' => '1']);
|
||||
}
|
||||
|
||||
private function appendPermission(array $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…
Reference in a new issue