A free open source IT asset/license management system
Add more tests for Asset Model index and store methods
Marcus Moore672aabf4ac9d
diff --git a/tests/Feature/AssetModels/Ui/AssetModelIndexTest.php b/tests/Feature/AssetModels/Ui/AssetModelIndexTest.phpnew file mode 100644index 0000000000..a73d425723--- /dev/null+++ b/tests/Feature/AssetModels/Ui/AssetModelIndexTest.php@@ -0,0 +1,23 @@+<?php++namespace Tests\Feature\AssetModels\Ui;++use App\Models\User;+use Tests\TestCase;++class AssetModelIndexTest extends TestCase+{+ public function testPermissionRequiredToViewAssetModelList()+ {+ $this->actingAs(User::factory()->create())+ ->get(route('models.index'))+ ->assertForbidden();+ }++ public function testUserCanListAssetModels()+ {+ $this->actingAs(User::factory()->superuser()->create())+ ->get(route('models.index'))+ ->assertOk();+ }+}diff --git a/tests/Feature/AssetModels/Ui/AssetModelStoreTest.php b/tests/Feature/AssetModels/Ui/AssetModelStoreTest.phpnew file mode 100644index 0000000000..81b07237c0--- /dev/null+++ b/tests/Feature/AssetModels/Ui/AssetModelStoreTest.php@@ -0,0 +1,35 @@+<?php++namespace Tests\Feature\AssetModels\Ui;++use App\Models\AssetModel;+use App\Models\Category;+use App\Models\User;+use Tests\TestCase;++class AssetModelStoreTest extends TestCase+{+ public function testPermissionRequiredToStoreAssetModel()+ {+ $this->actingAs(User::factory()->create())+ ->post(route('models.store'), [+ 'name' => 'Test Model',+ 'category_id' => Category::factory()->create()->id+ ])+ ->assertForbidden();+ }++ public function testUserCanCreateAssetModels()+ {+ $this->assertFalse(AssetModel::where('name', 'Test Model')->exists());++ $this->actingAs(User::factory()->superuser()->create())+ ->post(route('models.store'), [+ 'name' => 'Test Model',+ 'category_id' => Category::factory()->create()->id+ ])+ ->assertRedirect(route('models.index'));++ $this->assertTrue(AssetModel::where('name', 'Test Model')->exists());+ }+}diff --git a/tests/Feature/AssetModels/Ui/AssetModelsTest.php b/tests/Feature/AssetModels/Ui/AssetModelsTest.phpdeleted file mode 100644index bb60a25fe5..0000000000--- a/tests/Feature/AssetModels/Ui/AssetModelsTest.php+++ /dev/null@@ -1,38 +0,0 @@-<?php--namespace Tests\Feature\AssetModels\Ui;--use App\Models\Category;-use App\Models\AssetModel;-use App\Models\Company;-use App\Models\CustomField;-use App\Models\Statuslabel;-use App\Models\Supplier;-use App\Models\User;-use Illuminate\Support\Facades\Crypt;-use Tests\TestCase;--class AssetModelsTest extends TestCase-{- public function testUserCanListAssetModels()- {-- $this->actingAs(User::factory()->superuser()->create())- ->get(route('models.index'))- ->assertStatus(200);-- }-- public function testUserCanCreateAssetModels()- {- $this->actingAs(User::factory()->superuser()->create())- ->post(route('models.index'), [- 'name' => 'Test Model',- 'category_id' => Category::factory()->create()->id- ])- ->assertStatus(302)- ->assertRedirect(route('models.index'));- }---}