Skip to content

A free open source IT asset/license management system

Add failing tests

Marcus Moored21d18d48306
diff --git a/tests/Unit/Mail/CheckinAssetMailTest.php b/tests/Unit/Mail/CheckinAssetMailTest.php
index f820a330cf..44cf098d5b 100644
--- a/tests/Unit/Mail/CheckinAssetMailTest.php
+++ b/tests/Unit/Mail/CheckinAssetMailTest.php
@@ -4,6 +4,7 @@ namespace Tests\Unit\Mail;
use App\Mail\CheckinAssetMail;
use App\Models\Asset;
+use App\Models\Location;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
@@ -33,10 +34,32 @@ class CheckinAssetMailTest extends TestCase
$luke = User::factory()
->forLocation(['name' => 'Tatooine'])
->create();
- $r2d2 = Asset::factory()->create(['location_id' => null]);
+ $r2d2 = Asset::factory()->create(['location_id' => null, 'rtd_location_id' => null]);
$mail = new CheckinAssetMail($r2d2, $luke, User::factory()->create(), null);
$mail->assertDontSeeInText(trans('general.location'));
}
+
+ #[Test]
+ public function shows_default_location_when_asset_has_one()
+ {
+ $r2d2 = Asset::factory()->create([
+ 'rtd_location_id' => Location::factory()->create(['name' => 'Yavin 4'])->id,
+ ]);
+
+ $mail = new CheckinAssetMail($r2d2, User::factory()->create(), User::factory()->create(), null);
+
+ $mail->assertSeeInOrderInText([trans('admin/hardware/form.default_location'), 'Yavin 4']);
+ }
+
+ #[Test]
+ public function does_not_show_default_location_when_asset_has_none()
+ {
+ $r2d2 = Asset::factory()->create(['rtd_location_id' => null]);
+
+ $mail = new CheckinAssetMail($r2d2, User::factory()->create(), User::factory()->create(), null);
+
+ $mail->assertDontSeeInText(trans('admin/hardware/form.default_location'));
+ }
}
diff --git a/tests/Unit/Mail/CheckoutAssetMailTest.php b/tests/Unit/Mail/CheckoutAssetMailTest.php
index 9e0db43287..2a30db454a 100644
--- a/tests/Unit/Mail/CheckoutAssetMailTest.php
+++ b/tests/Unit/Mail/CheckoutAssetMailTest.php
@@ -130,10 +130,32 @@ class CheckoutAssetMailTest extends TestCase
public function does_not_show_location_when_user_has_no_location()
{
$han = User::factory()->create(['location_id' => null]);
- $r2d2 = Asset::factory()->create();
+ $r2d2 = Asset::factory()->create(['rtd_location_id' => null]);
$mail = new CheckoutAssetMail($r2d2, $han, User::factory()->create(), null, null);
$mail->assertDontSeeInText(trans('general.location'));
}
+
+ #[Test]
+ public function shows_default_location_when_asset_has_one()
+ {
+ $r2d2 = Asset::factory()->create([
+ 'rtd_location_id' => Location::factory()->create(['name' => 'Yavin 4'])->id,
+ ]);
+
+ $mail = new CheckoutAssetMail($r2d2, User::factory()->create(), User::factory()->create(), null, null);
+
+ $mail->assertSeeInOrderInText([trans('admin/hardware/form.default_location'), 'Yavin 4']);
+ }
+
+ #[Test]
+ public function does_not_show_default_location_when_asset_has_none()
+ {
+ $r2d2 = Asset::factory()->create(['rtd_location_id' => null]);
+
+ $mail = new CheckoutAssetMail($r2d2, User::factory()->create(), User::factory()->create(), null, null);
+
+ $mail->assertDontSeeInText(trans('admin/hardware/form.default_location'));
+ }
}