Skip to content

Commit 6022e6a

Browse files
committed
Test cleanups
1 parent e80a965 commit 6022e6a

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

tests/Feature/Users/TransferUserItemsAcceptanceCleanupTest.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,26 @@ public function transferring_license_seat_clears_source_users_pending_acceptance
3737
'reassignable' => 1,
3838
'category_id' => Category::factory()->forLicenses()->requiresAcceptance()->doesNotSendCheckinEmail(),
3939
]);
40+
4041
$seat = LicenseSeat::factory()->assignedToUser($source)->create(['license_id' => $license->id]);
4142

42-
$this->assertFalse((bool) $license->checkin_email(), 'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.');
43+
$this->assertFalse(
44+
(bool) $license->checkin_email(),
45+
'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.'
46+
);
4347

44-
// A real seat acceptance is keyed to the SEAT — LicenseSeat::class plus
45-
// the seat's own id — which is what CreateCheckoutAcceptanceAction
46-
// writes. There is no morph map aliasing License and LicenseSeat.
4748
$acceptance = CheckoutAcceptance::factory()->forLicenseSeat()->pending()->create([
4849
'checkoutable_id' => $seat->id,
4950
'assigned_to_id' => $source->id,
5051
]);
5152

5253
$this->transfer($source, $target, ['license_seat_ids' => [$seat->id]]);
5354

54-
// A seat that gets skipped never reaches the cleanup at all, so prove
55-
// the seat actually moved before drawing any conclusion from the
56-
// acceptance row.
57-
$this->assertSame($target->id, $seat->refresh()->assigned_to, 'The seat was skipped, so the cleanup never ran.');
55+
$this->assertSame(
56+
$target->id,
57+
$seat->refresh()->assigned_to,
58+
'The seat was skipped, so the cleanup never ran.'
59+
);
5860

5961
$this->assertAcceptanceWasSoftDeleted($acceptance);
6062
}
@@ -73,11 +75,11 @@ public function transferring_license_seat_leaves_pending_acceptance_for_another_
7375
$transferredSeat = LicenseSeat::factory()->assignedToUser($source)->create(['license_id' => $license->id]);
7476
$retainedSeat = LicenseSeat::factory()->assignedToUser($source)->create(['license_id' => $license->id]);
7577

76-
$this->assertFalse((bool) $license->checkin_email(), 'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.');
78+
$this->assertFalse(
79+
(bool) $license->checkin_email(),
80+
'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.'
81+
);
7782

78-
// The source user holds two seats of the same license and only one of
79-
// them is transferred. The cleanup has to key on the seat, not on the
80-
// license, or the retained seat's acceptance goes with it.
8183
$retainedAcceptance = CheckoutAcceptance::factory()->forLicenseSeat()->pending()->create([
8284
'checkoutable_id' => $retainedSeat->id,
8385
'assigned_to_id' => $source->id,
@@ -105,7 +107,10 @@ public function transferring_accessory_clears_only_the_source_users_pending_acce
105107
'qty' => 5,
106108
]);
107109

108-
$this->assertFalse((bool) $accessory->checkin_email(), 'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.');
110+
$this->assertFalse(
111+
(bool) $accessory->checkin_email(),
112+
'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.'
113+
);
109114

110115
$sourceCheckout = $accessory->checkouts()->where('assigned_to', $source->id)->firstOrFail();
111116

@@ -144,7 +149,10 @@ public function transferring_asset_clears_source_users_pending_acceptance(): voi
144149
]),
145150
]);
146151

147-
$this->assertFalse((bool) $asset->fresh()->checkin_email(), 'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.');
152+
$this->assertFalse(
153+
(bool) $asset->fresh()->checkin_email(),
154+
'Checkin email must be off, or this stops proving cleanup happens with notifications disabled.'
155+
);
148156

149157
$acceptance = CheckoutAcceptance::factory()->pending()->create([
150158
'checkoutable_id' => $asset->id,
@@ -159,11 +167,6 @@ public function transferring_asset_clears_source_users_pending_acceptance(): voi
159167
$this->assertSame(User::class, $asset->assigned_type);
160168

161169
$this->assertAcceptanceWasSoftDeleted($acceptance);
162-
163-
// Deliberately not asserting anything about pendings belonging to other
164-
// users for this same asset. The asset cleanup is over-broad today (no
165-
// assigned_to_id filter) and may be narrowed later; pinning that here
166-
// would make the narrowing look like a regression.
167170
}
168171

169172
private function transfer(User $source, User $target, array $items): void

0 commit comments

Comments
 (0)