Merge pull request #16335 from snipe/added_label_test

Added label test
This commit is contained in:
snipe 2025-02-25 10:40:46 +00:00 committed by GitHub
commit a4587f6322
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,36 @@
<?php
namespace Tests\Feature\Assets\Ui;
use App\Models\Accessory;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\User;
use Tests\TestCase;
class AssetLabelTest extends TestCase
{
public function testUserWithPermissionsCanAccessPage()
{
$assets = Asset::factory()->count(20)->create();
$id_array = $assets->pluck('id')->toArray();
$this->actingAs(User::factory()->viewAssets()->create())->post('/hardware/bulkedit', [
'ids' => $id_array,
'bulk_actions' => 'labels',
])->assertStatus(200);
}
public function testRedirectOfNoAssetsSelected()
{
$id_array = [];
$this->actingAs(User::factory()->viewAssets()->create())
->from(route('hardware.index'))
->post('/hardware/bulkedit', [
'ids' => $id_array,
'bulk_actions' => 'Labels',
])->assertStatus(302)
->assertRedirect(route('hardware.index'));
}
}