mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -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();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -72,4 +50,26 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany
|
||||||
$this->assertNotSoftDeleted($accessoryB);
|
$this->assertNotSoftDeleted($accessoryB);
|
||||||
$this->assertSoftDeleted($accessoryC);
|
$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();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -65,4 +54,15 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC
|
||||||
$this->assertNotSoftDeleted($assetMaintenanceB);
|
$this->assertNotSoftDeleted($assetMaintenanceB);
|
||||||
$this->assertSoftDeleted($assetMaintenanceC);
|
$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();
|
->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()
|
public function testCannotDeleteAssetModelThatStillHasAssociatedAssets()
|
||||||
{
|
{
|
||||||
$assetModel = Asset::factory()->create()->model;
|
$assetModel = Asset::factory()->create()->model;
|
||||||
|
@ -40,4 +29,15 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem
|
||||||
|
|
||||||
$this->assertNotSoftDeleted($assetModel);
|
$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();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -66,4 +50,20 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo
|
||||||
$this->assertNotSoftDeleted($assetB);
|
$this->assertNotSoftDeleted($assetB);
|
||||||
$this->assertSoftDeleted($assetC);
|
$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();
|
->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()
|
public function testCannotDeleteCategoryThatStillHasAssociatedItems()
|
||||||
{
|
{
|
||||||
$asset = Asset::factory()->create();
|
$asset = Asset::factory()->create();
|
||||||
|
@ -41,4 +30,15 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme
|
||||||
|
|
||||||
$this->assertNotSoftDeleted($category);
|
$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();
|
->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()
|
public function testCannotDeleteCompanyThatHasAssociatedItems()
|
||||||
{
|
{
|
||||||
$companyWithAssets = Company::factory()->hasAssets()->create();
|
$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' => $companyWithComponents->id]);
|
||||||
$this->assertDatabaseHas('companies', ['id' => $companyWithUsers->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();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -61,4 +50,15 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS
|
||||||
$this->assertNotSoftDeleted($componentB);
|
$this->assertNotSoftDeleted($componentB);
|
||||||
$this->assertSoftDeleted($componentC);
|
$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();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
@ -61,4 +50,15 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany
|
||||||
$this->assertNotSoftDeleted($consumableB);
|
$this->assertNotSoftDeleted($consumableB);
|
||||||
$this->assertSoftDeleted($consumableC);
|
$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();
|
->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()
|
public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets()
|
||||||
{
|
{
|
||||||
$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');
|
$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]);
|
$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();
|
->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()
|
public function testCannotDeleteCustomFieldsetWithAssociatedFields()
|
||||||
{
|
{
|
||||||
$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');
|
$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]);
|
$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
|
class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanySupport, TestsPermissionsRequirement
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testRequiresPermission()
|
public function testRequiresPermission()
|
||||||
{
|
{
|
||||||
$department = Department::factory()->create();
|
$department = Department::factory()->create();
|
||||||
|
@ -21,28 +20,6 @@ class DeleteDepartmentTest extends TestCase implements TestsMultipleFullCompanyS
|
||||||
->assertForbidden();
|
->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()
|
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$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->assertNotNull($departmentB->fresh(), 'Department unexpectedly deleted');
|
||||||
$this->assertNull($departmentC->fresh(), 'Department was not 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();
|
->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()
|
public function testCannotDeleteDepreciationThatHasAssociatedModels()
|
||||||
{
|
{
|
||||||
$depreciation = Depreciation::factory()->hasModels()->create();
|
$depreciation = Depreciation::factory()->hasModels()->create();
|
||||||
|
@ -39,4 +28,15 @@ class DeleteDepreciationTest extends TestCase implements TestsPermissionsRequire
|
||||||
|
|
||||||
$this->assertNotNull($depreciation->fresh(), 'Depreciation unexpectedly deleted');
|
$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;
|
namespace Tests\Feature\Suppliers\Api;
|
||||||
|
|
||||||
use App\Models\Asset;
|
|
||||||
use App\Models\AssetMaintenance;
|
use App\Models\AssetMaintenance;
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
Loading…
Reference in a new issue