Skip to content

A free open source IT asset/license management system

Improve tests around assets

Marcus Moore5aad15256c01
diff --git a/tests/Feature/Assets/Ui/EditAssetTest.php b/tests/Feature/Assets/Ui/EditAssetTest.php
index 0e1432e893..554b2f1487 100644
--- a/tests/Feature/Assets/Ui/EditAssetTest.php
+++ b/tests/Feature/Assets/Ui/EditAssetTest.php
@@ -15,7 +15,7 @@ use Tests\TestCase;
class EditAssetTest extends TestCase
{
- public function testPermissionRequiredToViewAsset()
+ public function testPermissionRequiredToViewEditAssetPage()
{
$asset = Asset::factory()->create();
$this->actingAs(User::factory()->create())
diff --git a/tests/Feature/Assets/Ui/ShowAssetTest.php b/tests/Feature/Assets/Ui/ShowAssetTest.php
index 23b6c8f31e..05920cc636 100644
--- a/tests/Feature/Assets/Ui/ShowAssetTest.php
+++ b/tests/Feature/Assets/Ui/ShowAssetTest.php
@@ -8,6 +8,23 @@ use Tests\TestCase;
class ShowAssetTest extends TestCase
{
+ public function testPermissionRequiredToViewAsset()
+ {
+ $this->actingAs(User::factory()->create())
+ ->get(route('hardware.show', Asset::factory()->create()))
+ ->assertForbidden();
+ }
+
+ public function testCanViewAsset()
+ {
+ $asset = Asset::factory()->create();
+
+ $this->actingAs(User::factory()->viewAssets()->create())
+ ->get(route('hardware.show', $asset))
+ ->assertSeeText($asset->asset_tag)
+ ->assertOk();
+ }
+
public function testPageForAssetWithMissingModelStillRenders()
{
$asset = Asset::factory()->create();
diff --git a/tests/Feature/Assets/Ui/StoreAssetsTest.php b/tests/Feature/Assets/Ui/StoreAssetsTest.php
index baa9babcc0..b6beb8da78 100644
--- a/tests/Feature/Assets/Ui/StoreAssetsTest.php
+++ b/tests/Feature/Assets/Ui/StoreAssetsTest.php
@@ -4,12 +4,30 @@ namespace Tests\Feature\Assets\Ui;
use App\Models\Asset;
use App\Models\AssetModel;
+use App\Models\Statuslabel;
use App\Models\User;
use Tests\TestCase;
class StoreAssetsTest extends TestCase
{
- public function testPageRenders()
+ public function testPermissionRequiredToViewCreateAssetPage()
+ {
+ $this->actingAs(User::factory()->create())
+ ->get(route('hardware.create'))
+ ->assertForbidden();
+ }
+
+ public function testPermissionRequiredToStoreAsset()
+ {
+ $this->actingAs(User::factory()->create())
+ ->post(route('hardware.store'), [
+ 'model_id' => AssetModel::factory()->create()->id,
+ 'status_id' => Statuslabel::factory()->create()->id,
+ ])
+ ->assertForbidden();
+ }
+
+ public function testCreateAssetPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
->get(route('hardware.create'))