Skip to content

A free open source IT asset/license management system

Revert "Inline some values"

Marcus Moore62b8e4c46f0b
diff --git a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
index 42d22fdfc3..f9846dd270 100644
--- a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
+++ b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
@@ -3,50 +3,37 @@
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 User $actor;
private User $assignedUser;
- private Category $categoryThatAlerts;
- private Category $categoryThatDoesNotAlert;
-
protected function setUp(): void
{
parent::setUp();
+ $this->asset = Asset::factory()->create();
$this->actor = User::factory()->checkoutAssets()->create();
$this->assignedUser = User::factory()->create();
-
- $this->categoryThatAlerts = Category::factory()->create([
- 'require_acceptance' => true,
- 'alert_on_response' => true,
- ]);
-
- $this->categoryThatDoesNotAlert = Category::factory()->create([
- 'require_acceptance' => true,
- 'alert_on_response' => false,
- ]);
}
public function test_sets_alert_on_response_if_enabled_by_category()
{
- $asset = Asset::factory()->create();
-
- $asset->model->update([
- 'category_id' => $this->categoryThatAlerts->id,
+ $this->asset->model->category->update([
+ 'require_acceptance' => true,
+ 'alert_on_response' => true,
]);
- $this->postCheckout($asset);
+ $this->postCheckout($this->asset);
$this->assertDatabaseHas('checkout_acceptances', [
'checkoutable_type' => Asset::class,
- 'checkoutable_id' => $asset->id,
+ 'checkoutable_id' => $this->asset->id,
'assigned_to_id' => $this->assignedUser->id,
'alert_on_response_id' => $this->actor->id,
]);
@@ -54,17 +41,16 @@ class SettingAlertOnResponseTest extends TestCase
public function test_does_not_set_alert_on_response_if_disabled_by_category()
{
- $asset = Asset::factory()->create();
-
- $asset->model->update([
- 'category_id' => $this->categoryThatDoesNotAlert->id,
+ $this->asset->model->category->update([
+ 'require_acceptance' => true,
+ 'alert_on_response' => false,
]);
- $this->postCheckout($asset);
+ $this->postCheckout($this->asset);
$this->assertDatabaseHas('checkout_acceptances', [
'checkoutable_type' => Asset::class,
- 'checkoutable_id' => $asset->id,
+ 'checkoutable_id' => $this->asset->id,
'assigned_to_id' => $this->assignedUser->id,
'alert_on_response_id' => null,
]);