Improve assertion

This commit is contained in:
Marcus Moore 2024-01-29 16:59:57 -08:00
parent 7d45cfff2c
commit a2cba67f4e
No known key found for this signature in database
2 changed files with 28 additions and 18 deletions

View file

@ -3,6 +3,7 @@
namespace Tests\Feature\Api\Accessories; namespace Tests\Feature\Api\Accessories;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Actionlog;
use App\Models\User; use App\Models\User;
use App\Notifications\CheckoutAccessoryNotification; use App\Notifications\CheckoutAccessoryNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
@ -78,14 +79,18 @@ class AccessoryCheckoutTest extends TestCase
'note' => 'oh hi there', 'note' => 'oh hi there',
]); ]);
$this->assertDatabaseHas('action_logs', [ $this->assertEquals(
'action_type' => 'checkout', 1,
'target_id' => $user->id, Actionlog::where([
'target_type' => User::class, 'action_type' => 'checkout',
'item_id' => $accessory->id, 'target_id' => $user->id,
'item_type' => Accessory::class, 'target_type' => User::class,
'user_id' => $actor->id, 'item_id' => $accessory->id,
'note' => 'oh hi there', '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'
);
} }
} }

View file

@ -3,6 +3,7 @@
namespace Tests\Feature\Checkouts; namespace Tests\Feature\Checkouts;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Actionlog;
use App\Models\User; use App\Models\User;
use App\Notifications\CheckoutAccessoryNotification; use App\Notifications\CheckoutAccessoryNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
@ -78,14 +79,18 @@ class AccessoryCheckoutTest extends TestCase
'note' => 'oh hi there', 'note' => 'oh hi there',
]); ]);
$this->assertDatabaseHas('action_logs', [ $this->assertEquals(
'action_type' => 'checkout', 1,
'target_id' => $user->id, Actionlog::where([
'target_type' => User::class, 'action_type' => 'checkout',
'item_id' => $accessory->id, 'target_id' => $user->id,
'item_type' => Accessory::class, 'target_type' => User::class,
'user_id' => $actor->id, 'item_id' => $accessory->id,
'note' => 'oh hi there', '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'
);
} }
} }