A free open source IT asset/license management system
Null guard for null created_at date
snipeaae07bd3a7da
diff --git a/app/Console/Commands/CleanIncorrectCheckoutAcceptances.php b/app/Console/Commands/CleanIncorrectCheckoutAcceptances.phpindex 623c8d0c6f..2364e9b2dc 100644--- a/app/Console/Commands/CleanIncorrectCheckoutAcceptances.php+++ b/app/Console/Commands/CleanIncorrectCheckoutAcceptances.php@@ -63,6 +63,13 @@ class CleanIncorrectCheckoutAcceptances extends Command}}+ if (is_null($checkoutAcceptance->created_at)) {+ $skips++;+ $bar->advance();++ continue;+ }+// Push all filtering (including the ±5-second window) into the DB;// exists() returns as soon as one matching row is found rather than// fetching all checkout logs into PHP.diff --git a/tests/Feature/Console/CleanIncorrectCheckoutAcceptancesTest.php b/tests/Feature/Console/CleanIncorrectCheckoutAcceptancesTest.phpindex e840264a69..22283d397d 100644--- a/tests/Feature/Console/CleanIncorrectCheckoutAcceptancesTest.php+++ b/tests/Feature/Console/CleanIncorrectCheckoutAcceptancesTest.php@@ -93,6 +93,15 @@ class CleanIncorrectCheckoutAcceptancesTest extends TestCase$this->assertDatabaseHas('checkout_acceptances', ['id' => $acceptance->id]);}+ public function test_skips_acceptance_with_null_created_at(): void+ {+ $acceptance = CheckoutAcceptance::factory()->withoutActionLog()->create(['created_at' => null]);++ $this->artisan('snipeit:clean-checkout-acceptances')->assertExitCode(0);++ $this->assertDatabaseHas('checkout_acceptances', ['id' => $acceptance->id]);+ }+public function test_deletes_license_seat_acceptance_when_checkout_target_is_non_user(){$location = Location::factory()->create();