Add assertions

This commit is contained in:
Marcus Moore 2024-08-05 16:02:59 -07:00
parent e3049fffd4
commit b06501dd02
No known key found for this signature in database

View file

@ -48,7 +48,7 @@ class BulkDeleteUsersTest extends TestCase
])->assertSessionHas('error')->assertRedirect(); ])->assertSessionHas('error')->assertRedirect();
} }
public function testAccessoryCheckinsAreProperlyLogged() public function testAccessoriesCanBeBulkCheckedIn()
{ {
[$accessoryA, $accessoryB] = Accessory::factory()->count(2)->create(); [$accessoryA, $accessoryB] = Accessory::factory()->count(2)->create();
[$userA, $userB, $userC] = User::factory()->count(3)->create(); [$userA, $userB, $userC] = User::factory()->count(3)->create();
@ -57,6 +57,10 @@ class BulkDeleteUsersTest extends TestCase
$this->attachAccessoryToUsers($accessoryA, [$userA, $userB, $userC]); $this->attachAccessoryToUsers($accessoryA, [$userA, $userB, $userC]);
$this->attachAccessoryToUsers($accessoryB, [$userA, $userB]); $this->attachAccessoryToUsers($accessoryB, [$userA, $userB]);
$this->assertTrue($userA->accessories->isNotEmpty());
$this->assertTrue($userB->accessories->isNotEmpty());
$this->assertTrue($userC->accessories->isNotEmpty());
$this->actingAs(User::factory()->editUsers()->create()) $this->actingAs(User::factory()->editUsers()->create())
->post(route('users/bulksave'), [ ->post(route('users/bulksave'), [
'ids' => [ 'ids' => [
@ -67,6 +71,10 @@ class BulkDeleteUsersTest extends TestCase
]) ])
->assertRedirect(); ->assertRedirect();
$this->assertTrue($userA->fresh()->accessories->isEmpty());
$this->assertTrue($userB->fresh()->accessories->isNotEmpty());
$this->assertTrue($userC->fresh()->accessories->isEmpty());
// These assertions check against a bug where the wrong value from // These assertions check against a bug where the wrong value from
// accessories_users was being populated in action_logs.item_id. // accessories_users was being populated in action_logs.item_id.
$this->assertActionLogCheckInEntryFor($userA, $accessoryA); $this->assertActionLogCheckInEntryFor($userA, $accessoryA);
@ -74,7 +82,7 @@ class BulkDeleteUsersTest extends TestCase
$this->assertActionLogCheckInEntryFor($userC, $accessoryA); $this->assertActionLogCheckInEntryFor($userC, $accessoryA);
} }
public function testConsumableCheckinsAreProperlyLogged() public function testConsumablesCanBeBulkCheckedIn()
{ {
[$consumableA, $consumableB] = Consumable::factory()->count(2)->create(); [$consumableA, $consumableB] = Consumable::factory()->count(2)->create();
[$userA, $userB, $userC] = User::factory()->count(3)->create(); [$userA, $userB, $userC] = User::factory()->count(3)->create();
@ -83,6 +91,10 @@ class BulkDeleteUsersTest extends TestCase
$this->attachConsumableToUsers($consumableA, [$userA, $userB, $userC]); $this->attachConsumableToUsers($consumableA, [$userA, $userB, $userC]);
$this->attachConsumableToUsers($consumableB, [$userA, $userB]); $this->attachConsumableToUsers($consumableB, [$userA, $userB]);
$this->assertTrue($userA->consumables->isNotEmpty());
$this->assertTrue($userB->consumables->isNotEmpty());
$this->assertTrue($userC->consumables->isNotEmpty());
$this->actingAs(User::factory()->editUsers()->create()) $this->actingAs(User::factory()->editUsers()->create())
->post(route('users/bulksave'), [ ->post(route('users/bulksave'), [
'ids' => [ 'ids' => [
@ -93,6 +105,10 @@ class BulkDeleteUsersTest extends TestCase
]) ])
->assertRedirect(); ->assertRedirect();
$this->assertTrue($userA->fresh()->consumables->isEmpty());
$this->assertTrue($userB->fresh()->consumables->isNotEmpty());
$this->assertTrue($userC->fresh()->consumables->isEmpty());
// These assertions check against a bug where the wrong value from // These assertions check against a bug where the wrong value from
// consumables_users was being populated in action_logs.item_id. // consumables_users was being populated in action_logs.item_id.
$this->assertActionLogCheckInEntryFor($userA, $consumableA); $this->assertActionLogCheckInEntryFor($userA, $consumableA);