mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Re-order test methods
This commit is contained in:
parent
4af893df61
commit
1fddacd7d0
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue