A free open source IT asset/license management system
Add another test case
Marcus Moore5e251505218e
diff --git a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.phpindex ac3a445c6f..c32f8d3472 100644--- a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php+++ b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php@@ -9,29 +9,60 @@ use Tests\TestCase;class SettingAlertOnResponseTest extends TestCase{- public function testSetsAlertOnResponseCorrectly()+ private Asset $asset;+ private User $actor;+ private User $assignedUser;++ protected function setUp(): void+ {+ 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(){- $asset = Asset::factory()->create();- $asset->model->category->update([+ $this->asset->model->category->update(['require_acceptance' => true,'alert_on_response' => true,]);- $actor = User::factory()->checkoutAssets()->create();- $assignedUser = User::factory()->create();+ $this->postCheckout();- $this->actingAs($actor)- ->post(route('hardware.checkout.store', $asset), [- 'checkout_to_type' => 'user',- 'status_id' => (string) Statuslabel::factory()->readyToDeploy()->create()->id,- 'assigned_user' => $assignedUser->id,- ]);+ $this->assertDatabaseHas('checkout_acceptances', [+ 'checkoutable_type' => Asset::class,+ 'checkoutable_id' => $this->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()+ {+ $this->asset->model->category->update([+ 'require_acceptance' => true,+ 'alert_on_response' => false,+ ]);++ $this->postCheckout();$this->assertDatabaseHas('checkout_acceptances', ['checkoutable_type' => Asset::class,- 'checkoutable_id' => $asset->id,- 'assigned_to_id' => $assignedUser->id,- 'alert_on_response_id' => $actor->id,+ 'checkoutable_id' => $this->asset->id,+ 'assigned_to_id' => $this->assignedUser->id,+ 'alert_on_response_id' => null,]);}++ private function postCheckout(): void+ {+ $this->actingAs($this->actor)+ ->post(route('hardware.checkout.store', $this->asset), [+ 'checkout_to_type' => 'user',+ 'status_id' => (string) Statuslabel::factory()->readyToDeploy()->create()->id,+ 'assigned_user' => $this->assignedUser->id,+ ]);+ }}