A free open source IT asset/license management system
oop, revert delete
spencerrlonggb61419c1cec7
diff --git a/tests/Feature/Suppliers/Api/DeleteSuppliersTest.php b/tests/Feature/Suppliers/Api/DeleteSuppliersTest.phpnew file mode 100644index 0000000000..06b85b75aa--- /dev/null+++ b/tests/Feature/Suppliers/Api/DeleteSuppliersTest.php@@ -0,0 +1,53 @@+<?php++namespace Tests\Feature\Suppliers\Api;++use App\Models\AssetMaintenance;+use App\Models\Supplier;+use App\Models\User;+use Tests\Concerns\TestsPermissionsRequirement;+use Tests\TestCase;++class DeleteSuppliersTest extends TestCase implements TestsPermissionsRequirement+{+ public function testRequiresPermission()+ {+ $supplier = Supplier::factory()->create();++ $this->actingAsForApi(User::factory()->create())+ ->deleteJson(route('api.suppliers.destroy', $supplier))+ ->assertForbidden();++ $this->assertNotSoftDeleted($supplier);+ }++ public function testCannotDeleteSupplierWithDataStillAssociated()+ {+ $supplierWithAsset = Supplier::factory()->hasAssets()->create();+ $supplierWithAssetMaintenance = Supplier::factory()->has(AssetMaintenance::factory(), 'asset_maintenances')->create();+ $supplierWithLicense = Supplier::factory()->hasLicenses()->create();++ $actor = $this->actingAsForApi(User::factory()->deleteSuppliers()->create());++ $actor->deleteJson(route('api.suppliers.destroy', $supplierWithAsset))->assertStatusMessageIs('error');+ $actor->deleteJson(route('api.suppliers.destroy', $supplierWithAssetMaintenance))->assertStatusMessageIs('error');+ $actor->deleteJson(route('api.suppliers.destroy', $supplierWithLicense))->assertStatusMessageIs('error');+++ $this->assertNotSoftDeleted($supplierWithAsset);+ $this->assertNotSoftDeleted($supplierWithAssetMaintenance);+ $this->assertNotSoftDeleted($supplierWithLicense);+ }++ public function testCanDeleteSupplier()+ {+ $supplier = Supplier::factory()->create();++ $this->actingAsForApi(User::factory()->deleteSuppliers()->create())+ ->deleteJson(route('api.suppliers.destroy', $supplier))+ ->assertOk()+ ->assertStatusMessageIs('success');++ $this->assertSoftDeleted($supplier);+ }+}diff --git a/tests/Feature/Suppliers/Ui/DeleteSuppliersTest.php b/tests/Feature/Suppliers/Ui/DeleteSuppliersTest.phpdeleted file mode 100644index 4a41670729..0000000000--- a/tests/Feature/Suppliers/Ui/DeleteSuppliersTest.php+++ /dev/null@@ -1,25 +0,0 @@-<?php--namespace Tests\Feature\Suppliers\Ui;--use Tests\Concerns\TestsPermissionsRequirement;-use Tests\TestCase;--class DeleteSuppliersTest extends TestCase implements TestsPermissionsRequirement-{- public function testRequiresPermission()- {- // TODO: Implement testRequiresPermission() method.- }-- public function test_cannot_delete_supplier_with_data_still_associated()- {- // TODO: Implement- }-- public function test_can_delete_supplier()- {- // TODO: implement- }--}\ No newline at end of file