diff --git a/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php b/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php index f36e5fbedd..8f2fabac6d 100644 --- a/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php +++ b/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php @@ -20,28 +20,6 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany ->assertForbidden(); } - public function testCanDeleteAccessory() - { - $accessory = Accessory::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteAccessories()->create()) - ->deleteJson(route('api.accessories.destroy', $accessory)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($accessory); - } - - public function testCannotDeleteAccessoryThatHasCheckouts() - { - $accessory = Accessory::factory()->checkedOutToUser()->create(); - - $this->actingAsForApi(User::factory()->deleteAccessories()->create()) - ->deleteJson(route('api.accessories.destroy', $accessory)) - ->assertStatusMessageIs('error'); - - $this->assertNotSoftDeleted($accessory); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -72,4 +50,26 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany $this->assertNotSoftDeleted($accessoryB); $this->assertSoftDeleted($accessoryC); } + + public function testCannotDeleteAccessoryThatHasCheckouts() + { + $accessory = Accessory::factory()->checkedOutToUser()->create(); + + $this->actingAsForApi(User::factory()->deleteAccessories()->create()) + ->deleteJson(route('api.accessories.destroy', $accessory)) + ->assertStatusMessageIs('error'); + + $this->assertNotSoftDeleted($accessory); + } + + public function testCanDeleteAccessory() + { + $accessory = Accessory::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteAccessories()->create()) + ->deleteJson(route('api.accessories.destroy', $accessory)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($accessory); + } } diff --git a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php b/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php index 80c570646e..06bf9bcd77 100644 --- a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php +++ b/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php @@ -20,17 +20,6 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC ->assertForbidden(); } - public function testCanDeleteAssetMaintenance() - { - $assetMaintenance = AssetMaintenance::factory()->create(); - - $this->actingAsForApi(User::factory()->editAssets()->create()) - ->deleteJson(route('api.maintenances.destroy', $assetMaintenance)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($assetMaintenance); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -65,4 +54,15 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC $this->assertNotSoftDeleted($assetMaintenanceB); $this->assertSoftDeleted($assetMaintenanceC); } + + public function testCanDeleteAssetMaintenance() + { + $assetMaintenance = AssetMaintenance::factory()->create(); + + $this->actingAsForApi(User::factory()->editAssets()->create()) + ->deleteJson(route('api.maintenances.destroy', $assetMaintenance)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($assetMaintenance); + } } diff --git a/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php b/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php index 8511d72d80..7de82db65b 100644 --- a/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php +++ b/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php @@ -19,17 +19,6 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem ->assertForbidden(); } - public function testCanDeleteAssetModel() - { - $assetModel = AssetModel::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteAssetModels()->create()) - ->deleteJson(route('api.models.destroy', $assetModel)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($assetModel); - } - public function testCannotDeleteAssetModelThatStillHasAssociatedAssets() { $assetModel = Asset::factory()->create()->model; @@ -40,4 +29,15 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem $this->assertNotSoftDeleted($assetModel); } + + public function testCanDeleteAssetModel() + { + $assetModel = AssetModel::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteAssetModels()->create()) + ->deleteJson(route('api.models.destroy', $assetModel)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($assetModel); + } } diff --git a/tests/Feature/Assets/Api/DeleteAssetsTest.php b/tests/Feature/Assets/Api/DeleteAssetsTest.php index fb1fc0cad0..d09d7d4034 100644 --- a/tests/Feature/Assets/Api/DeleteAssetsTest.php +++ b/tests/Feature/Assets/Api/DeleteAssetsTest.php @@ -20,22 +20,6 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo ->assertForbidden(); } - public function testCanDeleteAsset() - { - $asset = Asset::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteAssets()->create()) - ->deleteJson(route('api.assets.destroy', $asset)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($asset); - } - - public function testCannotDeleteAssetThatIsCheckedOut() - { - $this->markTestSkipped('This behavior is not functioning yet.'); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -66,4 +50,20 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo $this->assertNotSoftDeleted($assetB); $this->assertSoftDeleted($assetC); } + + public function testCannotDeleteAssetThatIsCheckedOut() + { + $this->markTestSkipped('This behavior is not functioning yet.'); + } + + public function testCanDeleteAsset() + { + $asset = Asset::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteAssets()->create()) + ->deleteJson(route('api.assets.destroy', $asset)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($asset); + } } diff --git a/tests/Feature/Categories/Api/DeleteCategoriesTest.php b/tests/Feature/Categories/Api/DeleteCategoriesTest.php index e4a28b7b98..2da03c3ca3 100644 --- a/tests/Feature/Categories/Api/DeleteCategoriesTest.php +++ b/tests/Feature/Categories/Api/DeleteCategoriesTest.php @@ -19,17 +19,6 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme ->assertForbidden(); } - public function testCanDeleteCategory() - { - $category = Category::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteCategories()->create()) - ->deleteJson(route('api.categories.destroy', $category)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($category); - } - public function testCannotDeleteCategoryThatStillHasAssociatedItems() { $asset = Asset::factory()->create(); @@ -41,4 +30,15 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme $this->assertNotSoftDeleted($category); } + + public function testCanDeleteCategory() + { + $category = Category::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteCategories()->create()) + ->deleteJson(route('api.categories.destroy', $category)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($category); + } } diff --git a/tests/Feature/Companies/Api/DeleteCompaniesTest.php b/tests/Feature/Companies/Api/DeleteCompaniesTest.php index 868dd36ab2..4ecc3c183f 100644 --- a/tests/Feature/Companies/Api/DeleteCompaniesTest.php +++ b/tests/Feature/Companies/Api/DeleteCompaniesTest.php @@ -18,17 +18,6 @@ class DeleteCompaniesTest extends TestCase implements TestsPermissionsRequiremen ->assertForbidden(); } - public function testCanDeleteCompany() - { - $company = Company::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteCompanies()->create()) - ->deleteJson(route('api.companies.destroy', $company)) - ->assertStatusMessageIs('success'); - - $this->assertDatabaseMissing('companies', ['id' => $company->id]); - } - public function testCannotDeleteCompanyThatHasAssociatedItems() { $companyWithAssets = Company::factory()->hasAssets()->create(); @@ -51,4 +40,15 @@ class DeleteCompaniesTest extends TestCase implements TestsPermissionsRequiremen $this->assertDatabaseHas('companies', ['id' => $companyWithComponents->id]); $this->assertDatabaseHas('companies', ['id' => $companyWithUsers->id]); } + + public function testCanDeleteCompany() + { + $company = Company::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteCompanies()->create()) + ->deleteJson(route('api.companies.destroy', $company)) + ->assertStatusMessageIs('success'); + + $this->assertDatabaseMissing('companies', ['id' => $company->id]); + } } diff --git a/tests/Feature/Components/Api/DeleteComponentsTest.php b/tests/Feature/Components/Api/DeleteComponentsTest.php index 89bd8ffc8c..c25e8a5500 100644 --- a/tests/Feature/Components/Api/DeleteComponentsTest.php +++ b/tests/Feature/Components/Api/DeleteComponentsTest.php @@ -20,17 +20,6 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS ->assertForbidden(); } - public function testCanDeleteComponents() - { - $component = Component::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteComponents()->create()) - ->deleteJson(route('api.components.destroy', $component)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($component); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -61,4 +50,15 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS $this->assertNotSoftDeleted($componentB); $this->assertSoftDeleted($componentC); } + + public function testCanDeleteComponents() + { + $component = Component::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteComponents()->create()) + ->deleteJson(route('api.components.destroy', $component)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($component); + } } diff --git a/tests/Feature/Consumables/Api/DeleteConsumablesTest.php b/tests/Feature/Consumables/Api/DeleteConsumablesTest.php index 72666a5d1a..fa50207ebe 100644 --- a/tests/Feature/Consumables/Api/DeleteConsumablesTest.php +++ b/tests/Feature/Consumables/Api/DeleteConsumablesTest.php @@ -20,17 +20,6 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany ->assertForbidden(); } - public function testCanDeleteConsumables() - { - $consumable = Consumable::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteConsumables()->create()) - ->deleteJson(route('api.consumables.destroy', $consumable)) - ->assertStatusMessageIs('success'); - - $this->assertSoftDeleted($consumable); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -61,4 +50,15 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany $this->assertNotSoftDeleted($consumableB); $this->assertSoftDeleted($consumableC); } + + public function testCanDeleteConsumables() + { + $consumable = Consumable::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteConsumables()->create()) + ->deleteJson(route('api.consumables.destroy', $consumable)) + ->assertStatusMessageIs('success'); + + $this->assertSoftDeleted($consumable); + } } diff --git a/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php b/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php index 72d8a06953..ef124b8214 100644 --- a/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php +++ b/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php @@ -21,19 +21,6 @@ class DeleteCustomFieldsTest extends TestCase implements TestsPermissionsRequire ->assertForbidden(); } - public function testCustomFieldsCanBeDeleted() - { - $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); - - $customField = CustomField::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteCustomFields()->create()) - ->deleteJson(route('api.customfields.destroy', $customField)) - ->assertStatusMessageIs('success'); - - $this->assertDatabaseMissing('custom_fields', ['id' => $customField->id]); - } - public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets() { $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); @@ -49,4 +36,17 @@ class DeleteCustomFieldsTest extends TestCase implements TestsPermissionsRequire $this->assertDatabaseHas('custom_fields', ['id' => $customField->id]); } + + public function testCustomFieldsCanBeDeleted() + { + $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); + + $customField = CustomField::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteCustomFields()->create()) + ->deleteJson(route('api.customfields.destroy', $customField)) + ->assertStatusMessageIs('success'); + + $this->assertDatabaseMissing('custom_fields', ['id' => $customField->id]); + } } diff --git a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php index 2610b4cff5..161b1cd4b1 100644 --- a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php +++ b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php @@ -21,19 +21,6 @@ class DeleteCustomFieldsetsTest extends TestCase implements TestsPermissionsRequ ->assertForbidden(); } - public function testCanDeleteCustomFieldsets() - { - $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); - - $customFieldset = CustomFieldset::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteCustomFieldsets()->create()) - ->deleteJson(route('api.fieldsets.destroy', $customFieldset)) - ->assertStatusMessageIs('success'); - - $this->assertDatabaseMissing('custom_fieldsets', ['id' => $customFieldset->id]); - } - public function testCannotDeleteCustomFieldsetWithAssociatedFields() { $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); @@ -62,4 +49,17 @@ class DeleteCustomFieldsetsTest extends TestCase implements TestsPermissionsRequ $this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]); } + + public function testCanDeleteCustomFieldsets() + { + $this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL'); + + $customFieldset = CustomFieldset::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteCustomFieldsets()->create()) + ->deleteJson(route('api.fieldsets.destroy', $customFieldset)) + ->assertStatusMessageIs('success'); + + $this->assertDatabaseMissing('custom_fieldsets', ['id' => $customFieldset->id]); + } } diff --git a/tests/Feature/Departments/Api/DeleteDepartmentTest.php b/tests/Feature/Departments/Api/DeleteDepartmentTest.php index 8e064b1566..3318767095 100644 --- a/tests/Feature/Departments/Api/DeleteDepartmentTest.php +++ b/tests/Feature/Departments/Api/DeleteDepartmentTest.php @@ -11,7 +11,6 @@ use Tests\TestCase; class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanySupport, TestsPermissionsRequirement { - public function testRequiresPermission() { $department = Department::factory()->create(); @@ -21,28 +20,6 @@ class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanyS ->assertForbidden(); } - public function testCanDeleteDepartment() - { - $department = Department::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteDepartments()->create()) - ->deleteJson(route('api.departments.destroy', $department)) - ->assertStatusMessageIs('success'); - - $this->assertDatabaseMissing('departments', ['id' => $department->id]); - } - - public function testCannotDeleteDepartmentThatStillHasUsers() - { - $department = Department::factory()->hasUsers()->create(); - - $this->actingAsForApi(User::factory()->deleteDepartments()->create()) - ->deleteJson(route('api.departments.destroy', $department)) - ->assertStatusMessageIs('error'); - - $this->assertNotNull($department->fresh(), 'Department unexpectedly deleted'); - } - public function testAdheresToMultipleFullCompanySupportScoping() { [$companyA, $companyB] = Company::factory()->count(2)->create(); @@ -73,4 +50,26 @@ class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanyS $this->assertNotNull($departmentB->fresh(), 'Department unexpectedly deleted'); $this->assertNull($departmentC->fresh(), 'Department was not deleted'); } + + public function testCannotDeleteDepartmentThatStillHasUsers() + { + $department = Department::factory()->hasUsers()->create(); + + $this->actingAsForApi(User::factory()->deleteDepartments()->create()) + ->deleteJson(route('api.departments.destroy', $department)) + ->assertStatusMessageIs('error'); + + $this->assertNotNull($department->fresh(), 'Department unexpectedly deleted'); + } + + public function testCanDeleteDepartment() + { + $department = Department::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteDepartments()->create()) + ->deleteJson(route('api.departments.destroy', $department)) + ->assertStatusMessageIs('success'); + + $this->assertDatabaseMissing('departments', ['id' => $department->id]); + } } diff --git a/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php b/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php index 2e93f92092..d45beb6aed 100644 --- a/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php +++ b/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php @@ -18,17 +18,6 @@ class DeleteDepreciationTest extends TestCase implements TestsPermissionsRequire ->assertForbidden(); } - public function testCanDeleteDepreciation() - { - $depreciation = Depreciation::factory()->create(); - - $this->actingAsForApi(User::factory()->deleteDepreciations()->create()) - ->deleteJson(route('api.depreciations.destroy', $depreciation)) - ->assertStatusMessageIs('success'); - - $this->assertDatabaseMissing('depreciations', ['id' => $depreciation->id]); - } - public function testCannotDeleteDepreciationThatHasAssociatedModels() { $depreciation = Depreciation::factory()->hasModels()->create(); @@ -39,4 +28,15 @@ class DeleteDepreciationTest extends TestCase implements TestsPermissionsRequire $this->assertNotNull($depreciation->fresh(), 'Depreciation unexpectedly deleted'); } + + public function testCanDeleteDepreciation() + { + $depreciation = Depreciation::factory()->create(); + + $this->actingAsForApi(User::factory()->deleteDepreciations()->create()) + ->deleteJson(route('api.depreciations.destroy', $depreciation)) + ->assertStatusMessageIs('success'); + + $this->assertDatabaseMissing('depreciations', ['id' => $depreciation->id]); + } } diff --git a/tests/Feature/Suppliers/Api/DeleteSupplierTest.php b/tests/Feature/Suppliers/Api/DeleteSupplierTest.php index 795ff2b576..f1600a963c 100644 --- a/tests/Feature/Suppliers/Api/DeleteSupplierTest.php +++ b/tests/Feature/Suppliers/Api/DeleteSupplierTest.php @@ -2,7 +2,6 @@ namespace Tests\Feature\Suppliers\Api; -use App\Models\Asset; use App\Models\AssetMaintenance; use App\Models\Supplier; use App\Models\User;