Skip to content

A free open source IT asset/license management system

Inline some values

Marcus Moore74b7d27408dc
diff --git a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
index f9846dd270..42d22fdfc3 100644
--- a/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
+++ b/tests/Feature/Checkouts/General/SettingAlertOnResponseTest.php
@@ -3,37 +3,50 @@
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()
{
- $this->asset->model->category->update([
- 'require_acceptance' => true,
- 'alert_on_response' => true,
+ $asset = Asset::factory()->create();
+
+ $asset->model->update([
+ 'category_id' => $this->categoryThatAlerts->id,
]);
- $this->postCheckout($this->asset);
+ $this->postCheckout($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,
]);
@@ -41,16 +54,17 @@ class SettingAlertOnResponseTest extends TestCase
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,
+ $asset = Asset::factory()->create();
+
+ $asset->model->update([
+ 'category_id' => $this->categoryThatDoesNotAlert->id,
]);
- $this->postCheckout($this->asset);
+ $this->postCheckout($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,
]);