mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Add failing test for api
This commit is contained in:
parent
8c21d625fc
commit
00cbebd1e3
|
@ -5,6 +5,7 @@ namespace Tests\Feature\Accessories\Api;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\Concerns\TestsFullMultipleCompaniesSupport;
|
use Tests\Concerns\TestsFullMultipleCompaniesSupport;
|
||||||
use Tests\Concerns\TestsPermissionsRequirement;
|
use Tests\Concerns\TestsPermissionsRequirement;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -53,9 +54,17 @@ class DeleteAccessoriesTest extends TestCase implements TestsFullMultipleCompani
|
||||||
$this->assertSoftDeleted($accessoryC);
|
$this->assertSoftDeleted($accessoryC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotDeleteAccessoryThatHasCheckouts()
|
public static function checkedOutAccessories()
|
||||||
{
|
{
|
||||||
$accessory = Accessory::factory()->checkedOutToUser()->create();
|
yield 'checked out to user' => [fn() => Accessory::factory()->checkedOutToUser()->create()];
|
||||||
|
yield 'checked out to asset' => [fn() => Accessory::factory()->checkedOutToAsset()->create()];
|
||||||
|
yield 'checked out to location' => [fn() => Accessory::factory()->checkedOutToLocation()->create()];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('checkedOutAccessories')]
|
||||||
|
public function testCannotDeleteAccessoryThatHasCheckouts($data)
|
||||||
|
{
|
||||||
|
$accessory = $data();
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->deleteAccessories()->create())
|
$this->actingAsForApi(User::factory()->deleteAccessories()->create())
|
||||||
->deleteJson(route('api.accessories.destroy', $accessory))
|
->deleteJson(route('api.accessories.destroy', $accessory))
|
||||||
|
|
Loading…
Reference in a new issue