Skip to content

Commit

Permalink
Unify assertion method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmoore committed Sep 16, 2024
1 parent 1fddacd commit f325c4a
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Feature/Accessories/Api/DeleteAccessoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.accessories.destroy', $accessory))
->assertForbidden();

$this->assertNotSoftDeleted($accessory);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.maintenances.destroy', $assetMaintenance))
->assertForbidden();

$this->assertNotSoftDeleted($assetMaintenance);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/AssetModels/Api/DeleteAssetModelsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.models.destroy', $assetModel))
->assertForbidden();

$this->assertNotSoftDeleted($assetModel);
}

public function testCannotDeleteAssetModelThatStillHasAssociatedAssets()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Assets/Api/DeleteAssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.assets.destroy', $asset))
->assertForbidden();

$this->assertNotSoftDeleted($asset);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Categories/Api/DeleteCategoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.categories.destroy', $category))
->assertForbidden();

$this->assertNotSoftDeleted($category);
}

public function testCannotDeleteCategoryThatStillHasAssociatedItems()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Companies/Api/DeleteCompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.companies.destroy', $company))
->assertForbidden();

$this->assertDatabaseHas('companies', ['id' => $company->id]);
}

public function testCannotDeleteCompanyThatHasAssociatedItems()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Components/Api/DeleteComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.components.destroy', $component))
->assertForbidden();

$this->assertNotSoftDeleted($component);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Consumables/Api/DeleteConsumablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.consumables.destroy', $consumable))
->assertForbidden();

$this->assertNotSoftDeleted($consumable);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/CustomFields/Api/DeleteCustomFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.customfields.destroy', $customField))
->assertForbidden();

$this->assertDatabaseHas('custom_fields', ['id' => $customField->id]);
}

public function testCustomFieldsCannotBeDeletedIfTheyHaveAssociatedFieldsets()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.fieldsets.destroy', $customFieldset))
->assertForbidden();

$this->assertDatabaseHas('custom_fieldsets', ['id' => $customFieldset->id]);
}

public function testCannotDeleteCustomFieldsetWithAssociatedFields()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Departments/Api/DeleteDepartmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.departments.destroy', $department))
->assertForbidden();

$this->assertDatabaseHas('departments', ['id' => $department->id]);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Depreciations/Api/DeleteDepreciationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.depreciations.destroy', $depreciation))
->assertForbidden();

$this->assertDatabaseHas('depreciations', ['id' => $depreciation->id]);
}

public function testCannotDeleteDepreciationThatHasAssociatedModels()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Groups/Api/DeleteGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.groups.destroy', $group))
->assertForbidden();

$this->assertDatabaseHas('permission_groups', ['id' => $group->id]);
}

public function testCanDeleteGroup()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Licenses/Api/DeleteLicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.licenses.destroy', $license))
->assertForbidden();

$this->assertNotSoftDeleted($license);
}

public function testAdheresToMultipleFullCompanySupportScoping()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/PredefinedKits/Api/DeletePredefinedKitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.kits.destroy', $predefinedKit))
->assertForbidden();

$this->assertDatabaseHas('kits', ['id' => $predefinedKit->id]);
}

public function testCanDeletePredefinedKits()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/StatusLabels/Api/DeleteStatusLabelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.statuslabels.destroy', $statusLabel))
->assertForbidden();

$this->assertNotSoftDeleted($statusLabel);
}

public function testCannotDeleteStatusLabelWhileStillAssociatedToAssets()
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Suppliers/Api/DeleteSupplierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function testRequiresPermission()
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.suppliers.destroy', $supplier))
->assertForbidden();

$this->assertNotSoftDeleted($supplier);
}

public function testCannotDeleteSupplierWithDataStillAssociated()
Expand Down

0 comments on commit f325c4a

Please sign in to comment.