Skip to content

A free open source IT asset/license management system

Improve assertion

Marcus Moorea2cba67f4e3a
diff --git a/tests/Feature/Api/Accessories/AccessoryCheckoutTest.php b/tests/Feature/Api/Accessories/AccessoryCheckoutTest.php
index 41070943c8..f4f49f0dbc 100644
--- a/tests/Feature/Api/Accessories/AccessoryCheckoutTest.php
+++ b/tests/Feature/Api/Accessories/AccessoryCheckoutTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Api\Accessories;
use App\Models\Accessory;
+use App\Models\Actionlog;
use App\Models\User;
use App\Notifications\CheckoutAccessoryNotification;
use Illuminate\Support\Facades\Notification;
@@ -78,14 +79,18 @@ class AccessoryCheckoutTest extends TestCase
'note' => 'oh hi there',
]);
- $this->assertDatabaseHas('action_logs', [
- 'action_type' => 'checkout',
- 'target_id' => $user->id,
- 'target_type' => User::class,
- 'item_id' => $accessory->id,
- 'item_type' => Accessory::class,
- 'user_id' => $actor->id,
- 'note' => 'oh hi there',
- ]);
+ $this->assertEquals(
+ 1,
+ Actionlog::where([
+ 'action_type' => 'checkout',
+ 'target_id' => $user->id,
+ 'target_type' => User::class,
+ 'item_id' => $accessory->id,
+ 'item_type' => Accessory::class,
+ 'user_id' => $actor->id,
+ 'note' => 'oh hi there',
+ ])->count(),
+ 'Log entry either does not exist or there are more than expected'
+ );
}
}
diff --git a/tests/Feature/Checkouts/AccessoryCheckoutTest.php b/tests/Feature/Checkouts/AccessoryCheckoutTest.php
index a61ca1eb76..74269bfbb9 100644
--- a/tests/Feature/Checkouts/AccessoryCheckoutTest.php
+++ b/tests/Feature/Checkouts/AccessoryCheckoutTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Checkouts;
use App\Models\Accessory;
+use App\Models\Actionlog;
use App\Models\User;
use App\Notifications\CheckoutAccessoryNotification;
use Illuminate\Support\Facades\Notification;
@@ -78,14 +79,18 @@ class AccessoryCheckoutTest extends TestCase
'note' => 'oh hi there',
]);
- $this->assertDatabaseHas('action_logs', [
- 'action_type' => 'checkout',
- 'target_id' => $user->id,
- 'target_type' => User::class,
- 'item_id' => $accessory->id,
- 'item_type' => Accessory::class,
- 'user_id' => $actor->id,
- 'note' => 'oh hi there',
- ]);
+ $this->assertEquals(
+ 1,
+ Actionlog::where([
+ 'action_type' => 'checkout',
+ 'target_id' => $user->id,
+ 'target_type' => User::class,
+ 'item_id' => $accessory->id,
+ 'item_type' => Accessory::class,
+ 'user_id' => $actor->id,
+ 'note' => 'oh hi there',
+ ])->count(),
+ 'Log entry either does not exist or there are more than expected'
+ );
}
}