Skip to content

Commit 3d97d8e

Browse files
committedMar 31, 2025
fix test setup
1 parent 027a872 commit 3d97d8e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

Diff for: ‎tests/Models/UserTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,16 @@ public function testUsernameChangeCostWindow(int $years, int $cost)
239239
$this->travelTo(CarbonImmutable::now()->subYears(3));
240240

241241
$user = User::factory()->create();
242-
while (CarbonImmutable::now()->isBefore($now)) {
242+
// every 6 months for 3 years = 6
243+
// using isBefore to setup adds too many when run at month boundaries.
244+
for ($i = 0; $i < 6; $i++) {
243245
$user->usernameChangeHistory()->create([
244246
'timestamp' => CarbonImmutable::now(),
245247
'type' => 'paid',
246248
'username' => 'marty',
247249
]);
248250

249-
$this->travelTo(CarbonImmutable::now()->addMonths(6));
251+
$this->travelTo(CarbonImmutable::now()->addMonthsNoOverflow(6));
250252
}
251253

252254
$this->travelTo($now->addYears($years));

0 commit comments

Comments
 (0)