From f325c4afdb234ab4ba820caac45bdf599a550c2f Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 16 Sep 2024 14:32:38 -0700 Subject: [PATCH] Unify assertion method --- tests/Feature/Accessories/Api/DeleteAccessoriesTest.php | 2 ++ .../AssetMaintenances/Api/DeleteAssetMaintenancesTest.php | 2 ++ tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php | 2 ++ tests/Feature/Assets/Api/DeleteAssetsTest.php | 2 ++ tests/Feature/Categories/Api/DeleteCategoriesTest.php | 2 ++ tests/Feature/Companies/Api/DeleteCompaniesTest.php | 2 ++ tests/Feature/Components/Api/DeleteComponentsTest.php | 2 ++ tests/Feature/Consumables/Api/DeleteConsumablesTest.php | 2 ++ tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php | 2 ++ tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php | 2 ++ tests/Feature/Departments/Api/DeleteDepartmentTest.php | 2 ++ tests/Feature/Depreciations/Api/DeleteDepreciationTest.php | 2 ++ tests/Feature/Groups/Api/DeleteGroupTest.php | 2 ++ tests/Feature/Licenses/Api/DeleteLicenseTest.php | 2 ++ tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php | 2 ++ tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php | 2 ++ tests/Feature/Suppliers/Api/DeleteSupplierTest.php | 2 ++ 17 files changed, 34 insertions(+) diff --git a/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php b/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php index 8f2fabac6d..aa5d7e5bcd 100644 --- a/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php +++ b/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php @@ -18,6 +18,8 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.accessories.destroy', $accessory)) ->assertForbidden(); + + $this->assertNotSoftDeleted($accessory); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php b/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php index 06bf9bcd77..ed7ed44447 100644 --- a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php +++ b/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php @@ -18,6 +18,8 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.maintenances.destroy', $assetMaintenance)) ->assertForbidden(); + + $this->assertNotSoftDeleted($assetMaintenance); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php b/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php index 7de82db65b..a079788651 100644 --- a/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php +++ b/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php @@ -17,6 +17,8 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.models.destroy', $assetModel)) ->assertForbidden(); + + $this->assertNotSoftDeleted($assetModel); } public function testCannotDeleteAssetModelThatStillHasAssociatedAssets() diff --git a/tests/Feature/Assets/Api/DeleteAssetsTest.php b/tests/Feature/Assets/Api/DeleteAssetsTest.php index d09d7d4034..95640ed83f 100644 --- a/tests/Feature/Assets/Api/DeleteAssetsTest.php +++ b/tests/Feature/Assets/Api/DeleteAssetsTest.php @@ -18,6 +18,8 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.assets.destroy', $asset)) ->assertForbidden(); + + $this->assertNotSoftDeleted($asset); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/Categories/Api/DeleteCategoriesTest.php b/tests/Feature/Categories/Api/DeleteCategoriesTest.php index 2da03c3ca3..eb9b73b050 100644 --- a/tests/Feature/Categories/Api/DeleteCategoriesTest.php +++ b/tests/Feature/Categories/Api/DeleteCategoriesTest.php @@ -17,6 +17,8 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.categories.destroy', $category)) ->assertForbidden(); + + $this->assertNotSoftDeleted($category); } public function testCannotDeleteCategoryThatStillHasAssociatedItems() diff --git a/tests/Feature/Companies/Api/DeleteCompaniesTest.php b/tests/Feature/Companies/Api/DeleteCompaniesTest.php index 4ecc3c183f..3dcdb4fd21 100644 --- a/tests/Feature/Companies/Api/DeleteCompaniesTest.php +++ b/tests/Feature/Companies/Api/DeleteCompaniesTest.php @@ -16,6 +16,8 @@ class DeleteCompaniesTest extends TestCase implements TestsPermissionsRequiremen $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.companies.destroy', $company)) ->assertForbidden(); + + $this->assertDatabaseHas('companies', ['id' => $company->id]); } public function testCannotDeleteCompanyThatHasAssociatedItems() diff --git a/tests/Feature/Components/Api/DeleteComponentsTest.php b/tests/Feature/Components/Api/DeleteComponentsTest.php index c25e8a5500..df965d745c 100644 --- a/tests/Feature/Components/Api/DeleteComponentsTest.php +++ b/tests/Feature/Components/Api/DeleteComponentsTest.php @@ -18,6 +18,8 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.components.destroy', $component)) ->assertForbidden(); + + $this->assertNotSoftDeleted($component); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/Consumables/Api/DeleteConsumablesTest.php b/tests/Feature/Consumables/Api/DeleteConsumablesTest.php index fa50207ebe..c57e2e0df8 100644 --- a/tests/Feature/Consumables/Api/DeleteConsumablesTest.php +++ b/tests/Feature/Consumables/Api/DeleteConsumablesTest.php @@ -18,6 +18,8 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.consumables.destroy', $consumable)) ->assertForbidden(); + + $this->assertNotSoftDeleted($consumable); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php b/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php index ef124b8214..ab40591e90 100644 --- a/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php +++ b/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php @@ -19,6 +19,8 @@ class DeleteCustomFieldsTest extends TestCase implements TestsPermissionsRequire $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.customfields.destroy', $customField)) ->assertForbidden(); + + $this->assertDatabaseHas('custom_fields', ['id' => $customField->id]); } public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets() diff --git a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php index 161b1cd4b1..c464323653 100644 --- a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php +++ b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php @@ -19,6 +19,8 @@ class DeleteCustomFieldsetsTest extends TestCase implements TestsPermissionsRequ $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.fieldsets.destroy', $customFieldset)) ->assertForbidden(); + + $this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]); } public function testCannotDeleteCustomFieldsetWithAssociatedFields() diff --git a/tests/Feature/Departments/Api/DeleteDepartmentTest.php b/tests/Feature/Departments/Api/DeleteDepartmentTest.php index 3318767095..5865a7f2e5 100644 --- a/tests/Feature/Departments/Api/DeleteDepartmentTest.php +++ b/tests/Feature/Departments/Api/DeleteDepartmentTest.php @@ -18,6 +18,8 @@ class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanyS $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.departments.destroy', $department)) ->assertForbidden(); + + $this->assertDatabaseHas('departments', ['id' => $department->id]); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php b/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php index d45beb6aed..a8ec45f6ed 100644 --- a/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php +++ b/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php @@ -16,6 +16,8 @@ class DeleteDepreciationTest extends TestCase implements TestsPermissionsRequire $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.depreciations.destroy', $depreciation)) ->assertForbidden(); + + $this->assertDatabaseHas('depreciations', ['id' => $depreciation->id]); } public function testCannotDeleteDepreciationThatHasAssociatedModels() diff --git a/tests/Feature/Groups/Api/DeleteGroupTest.php b/tests/Feature/Groups/Api/DeleteGroupTest.php index 8d057a7ed3..ec0766340b 100644 --- a/tests/Feature/Groups/Api/DeleteGroupTest.php +++ b/tests/Feature/Groups/Api/DeleteGroupTest.php @@ -16,6 +16,8 @@ class DeleteGroupTest extends TestCase implements TestsPermissionsRequirement $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.groups.destroy', $group)) ->assertForbidden(); + + $this->assertDatabaseHas('permission_groups', ['id' => $group->id]); } public function testCanDeleteGroup() diff --git a/tests/Feature/Licenses/Api/DeleteLicenseTest.php b/tests/Feature/Licenses/Api/DeleteLicenseTest.php index c41c0eca88..5261c339e6 100644 --- a/tests/Feature/Licenses/Api/DeleteLicenseTest.php +++ b/tests/Feature/Licenses/Api/DeleteLicenseTest.php @@ -18,6 +18,8 @@ class DeleteLicenseTest extends TestCase implements TestsMultipleFullCompanySupp $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.licenses.destroy', $license)) ->assertForbidden(); + + $this->assertNotSoftDeleted($license); } public function testAdheresToMultipleFullCompanySupportScoping() diff --git a/tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php b/tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php index e5eb544149..265278a302 100644 --- a/tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php +++ b/tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php @@ -17,6 +17,8 @@ class DeletePredefinedKitTest extends TestCase implements TestsPermissionsRequir $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.kits.destroy', $predefinedKit)) ->assertForbidden(); + + $this->assertDatabaseHas('kits', ['id' => $predefinedKit->id]); } public function testCanDeletePredefinedKits() diff --git a/tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php b/tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php index b7e92dcf22..46b8c6a61d 100644 --- a/tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php +++ b/tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php @@ -16,6 +16,8 @@ class DeleteStatusLabelTest extends TestCase implements TestsPermissionsRequirem $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.statuslabels.destroy', $statusLabel)) ->assertForbidden(); + + $this->assertNotSoftDeleted($statusLabel); } public function testCannotDeleteStatusLabelWhileStillAssociatedToAssets() diff --git a/tests/Feature/Suppliers/Api/DeleteSupplierTest.php b/tests/Feature/Suppliers/Api/DeleteSupplierTest.php index f1600a963c..fd619cf7bd 100644 --- a/tests/Feature/Suppliers/Api/DeleteSupplierTest.php +++ b/tests/Feature/Suppliers/Api/DeleteSupplierTest.php @@ -17,6 +17,8 @@ class DeleteSupplierTest extends TestCase implements TestsPermissionsRequirement $this->actingAsForApi(User::factory()->create()) ->deleteJson(route('api.suppliers.destroy', $supplier)) ->assertForbidden(); + + $this->assertNotSoftDeleted($supplier); } public function testCannotDeleteSupplierWithDataStillAssociated()