Skip to content

A free open source IT asset/license management system

Scaffold some test cases

Marcus Moore6586858284b8
diff --git a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
index c32f8d3472..29da7990e8 100644
--- a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
+++ b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
@@ -3,13 +3,15 @@
namespace Tests\Feature\Checkouts\General;
use App\Models\Asset;
+use App\Models\Category;
use App\Models\Statuslabel;
use App\Models\User;
use Tests\TestCase;
class SettingAlertOnResponseTest extends TestCase
{
- private Asset $asset;
+ private Category $categoryThatAlerts;
+ private Category $categoryThatDoesNotAlert;
private User $actor;
private User $assignedUser;
@@ -17,49 +19,94 @@ class SettingAlertOnResponseTest extends TestCase
{
parent::setUp();
- $this->asset = Asset::factory()->create();
$this->actor = User::factory()->checkoutAssets()->create();
$this->assignedUser = User::factory()->create();
- }
-
- public function test_sets_alert_on_response_if_enabled_by_category()
- {
- $this->asset->model->category->update([
+ $this->categoryThatAlerts = Category::factory()->create([
'require_acceptance' => true,
'alert_on_response' => true,
]);
+ $this->categoryThatDoesNotAlert = Category::factory()->create([
+ 'require_acceptance' => true,
+ 'alert_on_response' => false,
+ ]);
+ }
- $this->postCheckout();
+ public function test_sets_alert_on_response_if_enabled_by_category_for_accessory()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_does_not_set_alert_on_response_if_disabled_by_category_for_accessory()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_sets_alert_on_response_if_enabled_by_category_for_asset()
+ {
+ $asset = Asset::factory()->create();
+
+ $asset->model->update(['category_id' => $this->categoryThatAlerts->id]);
+
+ $this->postAssetCheckout($asset);
$this->assertDatabaseHas('checkout_acceptances', [
'checkoutable_type' => Asset::class,
- 'checkoutable_id' => $this->asset->id,
+ 'checkoutable_id' => $asset->id,
'assigned_to_id' => $this->assignedUser->id,
'alert_on_response_id' => $this->actor->id,
]);
}
- public function test_does_not_set_alert_on_response_if_disabled_by_category()
+ public function test_does_not_set_alert_on_response_if_disabled_by_category_for_asset()
{
- $this->asset->model->category->update([
- 'require_acceptance' => true,
- 'alert_on_response' => false,
- ]);
+ $asset = Asset::factory()->create();
- $this->postCheckout();
+ $asset->model->update(['category_id' => $this->categoryThatDoesNotAlert->id]);
+
+ $this->postAssetCheckout($asset);
$this->assertDatabaseHas('checkout_acceptances', [
'checkoutable_type' => Asset::class,
- 'checkoutable_id' => $this->asset->id,
+ 'checkoutable_id' => $asset->id,
'assigned_to_id' => $this->assignedUser->id,
'alert_on_response_id' => null,
]);
}
- private function postCheckout(): void
+ public function test_sets_alert_on_response_if_enabled_by_category_for_component()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_does_not_set_alert_on_response_if_disabled_by_category_for_component()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_sets_alert_on_response_if_enabled_by_category_for_consumable()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_does_not_set_alert_on_response_if_disabled_by_category_for_consumable()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_sets_alert_on_response_if_enabled_by_category_for_license()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function test_does_not_set_alert_on_response_if_disabled_by_category_for_license()
+ {
+ $this->markTestIncomplete();
+ }
+
+ private function postAssetCheckout(Asset $asset): void
{
$this->actingAs($this->actor)
- ->post(route('hardware.checkout.store', $this->asset), [
+ ->post(route('hardware.checkout.store', $asset), [
'checkout_to_type' => 'user',
'status_id' => (string) Statuslabel::factory()->readyToDeploy()->create()->id,
'assigned_user' => $this->assignedUser->id,