mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Improve assertions
This commit is contained in:
parent
b8b3f91ce4
commit
4af893df61
|
@ -28,7 +28,7 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany
|
|||
->deleteJson(route('api.accessories.destroy', $accessory))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($accessory->fresh()->trashed());
|
||||
$this->assertSoftDeleted($accessory);
|
||||
}
|
||||
|
||||
public function testCannotDeleteAccessoryThatHasCheckouts()
|
||||
|
@ -39,7 +39,7 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany
|
|||
->deleteJson(route('api.accessories.destroy', $accessory))
|
||||
->assertStatusMessageIs('error');
|
||||
|
||||
$this->assertFalse($accessory->fresh()->trashed());
|
||||
$this->assertNotSoftDeleted($accessory);
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
|
@ -68,8 +68,8 @@ class DeleteAccessoriesTest extends TestCase implements TestsMultipleFullCompany
|
|||
->deleteJson(route('api.accessories.destroy', $accessoryC))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertNull($accessoryA->fresh()->deleted_at, 'Accessory unexpectedly deleted');
|
||||
$this->assertNull($accessoryB->fresh()->deleted_at, 'Accessory unexpectedly deleted');
|
||||
$this->assertNotNull($accessoryC->fresh()->deleted_at, 'Accessory was not deleted');
|
||||
$this->assertNotSoftDeleted($accessoryA);
|
||||
$this->assertNotSoftDeleted($accessoryB);
|
||||
$this->assertSoftDeleted($accessoryC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC
|
|||
->deleteJson(route('api.maintenances.destroy', $assetMaintenance))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($assetMaintenance->fresh()->trashed());
|
||||
$this->assertSoftDeleted($assetMaintenance);
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
|
@ -61,8 +61,8 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsMultipleFullC
|
|||
->deleteJson(route('api.maintenances.destroy', $assetMaintenanceC))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertNull($assetMaintenanceA->fresh()->deleted_at, 'Asset Maintenance unexpectedly deleted');
|
||||
$this->assertNull($assetMaintenanceB->fresh()->deleted_at, 'Asset Maintenance unexpectedly deleted');
|
||||
$this->assertNotNull($assetMaintenanceC->fresh()->deleted_at, 'Asset Maintenance was not deleted');
|
||||
$this->assertNotSoftDeleted($assetMaintenanceA);
|
||||
$this->assertNotSoftDeleted($assetMaintenanceB);
|
||||
$this->assertSoftDeleted($assetMaintenanceC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem
|
|||
->deleteJson(route('api.models.destroy', $assetModel))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($assetModel->fresh()->trashed());
|
||||
$this->assertSoftDeleted($assetModel);
|
||||
}
|
||||
|
||||
public function testCannotDeleteAssetModelThatStillHasAssociatedAssets()
|
||||
|
@ -38,6 +38,6 @@ class DeleteAssetModelsTest extends TestCase implements TestsPermissionsRequirem
|
|||
->deleteJson(route('api.models.destroy', $assetModel))
|
||||
->assertStatusMessageIs('error');
|
||||
|
||||
$this->assertFalse($assetModel->fresh()->trashed());
|
||||
$this->assertNotSoftDeleted($assetModel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo
|
|||
->deleteJson(route('api.assets.destroy', $asset))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($asset->fresh()->trashed());
|
||||
$this->assertSoftDeleted($asset);
|
||||
}
|
||||
|
||||
public function testCannotDeleteAssetThatIsCheckedOut()
|
||||
|
@ -62,8 +62,8 @@ class DeleteAssetsTest extends TestCase implements TestsMultipleFullCompanySuppo
|
|||
->deleteJson(route('api.assets.destroy', $assetC))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertNull($assetA->fresh()->deleted_at, 'Asset unexpectedly deleted');
|
||||
$this->assertNull($assetB->fresh()->deleted_at, 'Asset unexpectedly deleted');
|
||||
$this->assertNotNull($assetC->fresh()->deleted_at, 'Asset was not deleted');
|
||||
$this->assertNotSoftDeleted($assetA);
|
||||
$this->assertNotSoftDeleted($assetB);
|
||||
$this->assertSoftDeleted($assetC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme
|
|||
->deleteJson(route('api.categories.destroy', $category))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($category->fresh()->trashed());
|
||||
$this->assertSoftDeleted($category);
|
||||
}
|
||||
|
||||
public function testCannotDeleteCategoryThatStillHasAssociatedItems()
|
||||
|
@ -39,6 +39,6 @@ class DeleteCategoriesTest extends TestCase implements TestsPermissionsRequireme
|
|||
->deleteJson(route('api.categories.destroy', $category))
|
||||
->assertStatusMessageIs('error');
|
||||
|
||||
$this->assertFalse($category->fresh()->trashed());
|
||||
$this->assertNotSoftDeleted($category);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,5 +44,11 @@ class DeleteCompaniesTest extends TestCase implements TestsPermissionsRequiremen
|
|||
$actor->deleteJson(route('api.companies.destroy', $companyWithConsumables))->assertStatusMessageIs('error');
|
||||
$actor->deleteJson(route('api.companies.destroy', $companyWithComponents))->assertStatusMessageIs('error');
|
||||
$actor->deleteJson(route('api.companies.destroy', $companyWithUsers))->assertStatusMessageIs('error');
|
||||
|
||||
$this->assertDatabaseHas('companies', ['id' => $companyWithAssets->id]);
|
||||
$this->assertDatabaseHas('companies', ['id' => $companyWithAccessories->id]);
|
||||
$this->assertDatabaseHas('companies', ['id' => $companyWithConsumables->id]);
|
||||
$this->assertDatabaseHas('companies', ['id' => $companyWithComponents->id]);
|
||||
$this->assertDatabaseHas('companies', ['id' => $companyWithUsers->id]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS
|
|||
->deleteJson(route('api.components.destroy', $component))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($component->fresh()->trashed());
|
||||
$this->assertSoftDeleted($component);
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
|
@ -57,8 +57,8 @@ class DeleteComponentsTest extends TestCase implements TestsMultipleFullCompanyS
|
|||
->deleteJson(route('api.components.destroy', $componentC))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertNull($componentA->fresh()->deleted_at, 'Component unexpectedly deleted');
|
||||
$this->assertNull($componentB->fresh()->deleted_at, 'Component unexpectedly deleted');
|
||||
$this->assertNotNull($componentC->fresh()->deleted_at, 'Component was not deleted');
|
||||
$this->assertNotSoftDeleted($componentA);
|
||||
$this->assertNotSoftDeleted($componentB);
|
||||
$this->assertSoftDeleted($componentC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany
|
|||
->deleteJson(route('api.consumables.destroy', $consumable))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertTrue($consumable->fresh()->trashed());
|
||||
$this->assertSoftDeleted($consumable);
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
|
@ -57,8 +57,8 @@ class DeleteConsumablesTest extends TestCase implements TestsMultipleFullCompany
|
|||
->deleteJson(route('api.consumables.destroy', $consumableC))
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$this->assertNull($consumableA->fresh()->deleted_at, 'Consumable unexpectedly deleted');
|
||||
$this->assertNull($consumableB->fresh()->deleted_at, 'Consumable unexpectedly deleted');
|
||||
$this->assertNotNull($consumableC->fresh()->deleted_at, 'Consumable was not deleted');
|
||||
$this->assertNotSoftDeleted($consumableA);
|
||||
$this->assertNotSoftDeleted($consumableB);
|
||||
$this->assertSoftDeleted($consumableC);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue