A free open source IT asset/license management system
Re-order test methods
Marcus Moore1fddacd7d044
diff --git a/tests/Feature/Accessories/Api/DeleteAccessoriesTest.php b/tests/Feature/Accessories/Api/DeleteAccessoriesTest.phpindex 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.phpindex 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.phpindex 8511d72d80..7de82db65b 100644--- a/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php+++ b/tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php@@ -19,25 +19,25 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem->assertForbidden();}- public function testCanDeleteAssetModel()+ public function testCannotDeleteAssetModelThatStillHasAssociatedAssets(){- $assetModel = AssetModel::factory()->create();+ $assetModel = Asset::factory()->create()->model;$this->actingAsForApi(User::factory()->deleteAssetModels()->create())->deleteJson(route('api.models.destroy', $assetModel))- ->assertStatusMessageIs('success');+ ->assertStatusMessageIs('error');- $this->assertSoftDeleted($assetModel);+ $this->assertNotSoftDeleted($assetModel);}- public function testCannotDeleteAssetModelThatStillHasAssociatedAssets()+ public function testCanDeleteAssetModel(){- $assetModel = Asset::factory()->create()->model;+ $assetModel = AssetModel::factory()->create();$this->actingAsForApi(User::factory()->deleteAssetModels()->create())->deleteJson(route('api.models.destroy', $assetModel))- ->assertStatusMessageIs('error');+ ->assertStatusMessageIs('success');- $this->assertNotSoftDeleted($assetModel);+ $this->assertSoftDeleted($assetModel);}}diff --git a/tests/Feature/Assets/Api/DeleteAssetsTest.php b/tests/Feature/Assets/Api/DeleteAssetsTest.phpindex 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.phpindex e4a28b7b98..2da03c3ca3 100644--- a/tests/Feature/Categories/Api/DeleteCategoriesTest.php+++ b/tests/Feature/Categories/Api/DeleteCategoriesTest.php@@ -19,26 +19,26 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme->assertForbidden();}- public function testCanDeleteCategory()+ public function testCannotDeleteCategoryThatStillHasAssociatedItems(){- $category = Category::factory()->create();+ $asset = Asset::factory()->create();+ $category = $asset->model->category;$this->actingAsForApi(User::factory()->deleteCategories()->create())->deleteJson(route('api.categories.destroy', $category))- ->assertStatusMessageIs('success');+ ->assertStatusMessageIs('error');- $this->assertSoftDeleted($category);+ $this->assertNotSoftDeleted($category);}- public function testCannotDeleteCategoryThatStillHasAssociatedItems()+ public function testCanDeleteCategory(){- $asset = Asset::factory()->create();- $category = $asset->model->category;+ $category = Category::factory()->create();$this->actingAsForApi(User::factory()->deleteCategories()->create())->deleteJson(route('api.categories.destroy', $category))- ->assertStatusMessageIs('error');+ ->assertStatusMessageIs('success');- $this->assertNotSoftDeleted($category);+ $this->assertSoftDeleted($category);}}diff --git a/tests/Feature/Companies/Api/DeleteCompaniesTest.php b/tests/Feature/Companies/Api/DeleteCompaniesTest.phpindex 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.phpindex 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.phpindex 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.phpindex 72d8a06953..ef124b8214 100644--- a/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php+++ b/tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php@@ -21,32 +21,32 @@ class DeleteCustomFieldsTest extends TestCase implements TestsPermissionsRequire->assertForbidden();}- public function testCustomFieldsCanBeDeleted()+ public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets(){$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');$customField = CustomField::factory()->create();+ $customFieldset = CustomFieldset::factory()->create();++ $customField->fieldset()->attach($customFieldset, ['order' => 1, 'required' => 'false']);$this->actingAsForApi(User::factory()->deleteCustomFields()->create())->deleteJson(route('api.customfields.destroy', $customField))- ->assertStatusMessageIs('success');+ ->assertStatusMessageIs('error');- $this->assertDatabaseMissing('custom_fields', ['id' => $customField->id]);+ $this->assertDatabaseHas('custom_fields', ['id' => $customField->id]);}- public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets()+ public function testCustomFieldsCanBeDeleted(){$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');$customField = CustomField::factory()->create();- $customFieldset = CustomFieldset::factory()->create();-- $customField->fieldset()->attach($customFieldset, ['order' => 1, 'required' => 'false']);$this->actingAsForApi(User::factory()->deleteCustomFields()->create())->deleteJson(route('api.customfields.destroy', $customField))- ->assertStatusMessageIs('error');+ ->assertStatusMessageIs('success');- $this->assertDatabaseHas('custom_fields', ['id' => $customField->id]);+ $this->assertDatabaseMissing('custom_fields', ['id' => $customField->id]);}}diff --git a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.phpindex 2610b4cff5..161b1cd4b1 100644--- a/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php+++ b/tests/Feature/CustomFieldsets/Api/DeleteCustomFieldsetsTest.php@@ -21,27 +21,27 @@ class DeleteCustomFieldsetsTest extends TestCase implements TestsPermissionsRequ->assertForbidden();}- public function testCanDeleteCustomFieldsets()+ public function testCannotDeleteCustomFieldsetWithAssociatedFields(){$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');+ $customField = CustomField::factory()->create();$customFieldset = CustomFieldset::factory()->create();+ $customField->fieldset()->attach($customFieldset, ['order' => 1, 'required' => 'false']);+$this->actingAsForApi(User::factory()->deleteCustomFieldsets()->create())->deleteJson(route('api.fieldsets.destroy', $customFieldset))- ->assertStatusMessageIs('success');+ ->assertStatusMessageIs('error');- $this->assertDatabaseMissing('custom_fieldsets', ['id' => $customFieldset->id]);+ $this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]);}- public function testCannotDeleteCustomFieldsetWithAssociatedFields()+ public function testCannotDeleteCustomFieldsetWithAssociatedModels(){$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');- $customField = CustomField::factory()->create();- $customFieldset = CustomFieldset::factory()->create();-- $customField->fieldset()->attach($customFieldset, ['order' => 1, 'required' => 'false']);+ $customFieldset = CustomFieldset::factory()->hasModels()->create();$this->actingAsForApi(User::factory()->deleteCustomFieldsets()->create())->deleteJson(route('api.fieldsets.destroy', $customFieldset))@@ -50,16 +50,16 @@ class DeleteCustomFieldsetsTest extends TestCase implements TestsPermissionsRequ$this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]);}- public function testCannotDeleteCustomFieldsetWithAssociatedModels()+ public function testCanDeleteCustomFieldsets(){$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');- $customFieldset = CustomFieldset::factory()->hasModels()->create();+ $customFieldset = CustomFieldset::factory()->create();$this->actingAsForApi(User::factory()->deleteCustomFieldsets()->create())->deleteJson(route('api.fieldsets.destroy', $customFieldset))- ->assertStatusMessageIs('error');+ ->assertStatusMessageIs('success');- $this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]);+ $this->assertDatabaseMissing('custom_fieldsets', ['id' => $customFieldset->id]);}}diff --git a/tests/Feature/Departments/Api/DeleteDepartmentTest.php b/tests/Feature/Departments/Api/DeleteDepartmentTest.phpindex 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.phpindex 2e93f92092..d45beb6aed 100644--- a/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php+++ b/tests/Feature/Depreciations/Api/DeleteDepreciationTest.php@@ -18,25 +18,25 @@ class DeleteDepreciationTest extends TestCase implements TestsPermissionsRequire->assertForbidden();}- public function testCanDeleteDepreciation()+ public function testCannotDeleteDepreciationThatHasAssociatedModels(){- $depreciation = Depreciation::factory()->create();+ $depreciation = Depreciation::factory()->hasModels()->create();$this->actingAsForApi(User::factory()->deleteDepreciations()->create())->deleteJson(route('api.depreciations.destroy', $depreciation))- ->assertStatusMessageIs('success');+ ->assertStatusMessageIs('error');- $this->assertDatabaseMissing('depreciations', ['id' => $depreciation->id]);+ $this->assertNotNull($depreciation->fresh(), 'Depreciation unexpectedly deleted');}- public function testCannotDeleteDepreciationThatHasAssociatedModels()+ public function testCanDeleteDepreciation(){- $depreciation = Depreciation::factory()->hasModels()->create();+ $depreciation = Depreciation::factory()->create();$this->actingAsForApi(User::factory()->deleteDepreciations()->create())->deleteJson(route('api.depreciations.destroy', $depreciation))- ->assertStatusMessageIs('error');+ ->assertStatusMessageIs('success');- $this->assertNotNull($depreciation->fresh(), 'Depreciation unexpectedly deleted');+ $this->assertDatabaseMissing('depreciations', ['id' => $depreciation->id]);}}diff --git a/tests/Feature/Suppliers/Api/DeleteSupplierTest.php b/tests/Feature/Suppliers/Api/DeleteSupplierTest.phpindex 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;