A free open source IT asset/license management system
Add test for importer
Marcus Moore256e989ba113
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.phpindex 5c885666df..10bb22e4eb 100644--- a/database/factories/UserFactory.php+++ b/database/factories/UserFactory.php@@ -296,6 +296,11 @@ class UserFactory extends Factoryreturn $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) {diff --git a/tests/Feature/Livewire/ImporterTest.php b/tests/Feature/Livewire/ImporterTest.phpnew file mode 100644index 0000000000..b8af8f9bc0--- /dev/null+++ b/tests/Feature/Livewire/ImporterTest.php@@ -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);+ }+}