mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add tests for delete asset model endpoint
This commit is contained in:
parent
b336c6273d
commit
2044570e95
|
@ -141,6 +141,11 @@ class UserFactory extends Factory
|
|||
return $this->appendPermission(['assets.view.requestable' => '1']);
|
||||
}
|
||||
|
||||
public function deleteAssetModels()
|
||||
{
|
||||
return $this->appendPermission(['models.delete' => '1']);
|
||||
}
|
||||
|
||||
public function viewAccessories()
|
||||
{
|
||||
return $this->appendPermission(['accessories.view' => '1']);
|
||||
|
|
51
tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php
Normal file
51
tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\AssetModels\Api;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\User;
|
||||
use Tests\Concerns\TestsMultipleFullCompanySupport;
|
||||
use Tests\Concerns\TestsPermissionsRequirement;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteAssetModelsTest extends TestCase implements TestsMultipleFullCompanySupport, TestsPermissionsRequirement
|
||||
{
|
||||
public function testRequiresPermission()
|
||||
{
|
||||
$assetModel = AssetModel::factory()->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->create())
|
||||
->deleteJson(route('api.models.destroy', $assetModel))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testCanDeleteAssetModel()
|
||||
{
|
||||
$assetModel = AssetModel::factory()->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->deleteAssetModels()->create())
|
||||
->deleteJson(route('api.models.destroy', $assetModel))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($assetModel->fresh()->trashed());
|
||||
}
|
||||
|
||||
public function testCannotDeleteAssetModelThatStillHasAssociatedAssets()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->deleteAssetModels()->create())
|
||||
->deleteJson(route('api.models.destroy', $asset->model))
|
||||
->assertStatusMessageIs('error');
|
||||
|
||||
$this->assertFalse($asset->model->fresh()->trashed());
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
{
|
||||
// TODO: Implement testAdheresToMultipleFullCompanySupportScoping() method.
|
||||
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue