From f881203af8d7f8ac0794edd5dd558f6e06e0b8de Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 22 Apr 2026 13:01:19 +0200 Subject: [PATCH] Add regression test for withoutPending At the moment, `Tenant::withoutPending()->where('id', 'nonexistent-id')->first()` incorrectly returns the first non-pending tenant --- tests/PendingTenantsTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/PendingTenantsTest.php b/tests/PendingTenantsTest.php index a90aceed..50081831 100644 --- a/tests/PendingTenantsTest.php +++ b/tests/PendingTenantsTest.php @@ -111,6 +111,15 @@ test('a new tenant gets created while pulling a pending tenant if the pending po expect(Tenant::withPending()->get()->count())->toBe(1); // All tenants }); +test('withoutPending chained with where clauses returns correct results', function() { + $tenant = Tenant::create(); + $pendingTenant = Tenant::createPending(); + + expect(Tenant::withoutPending()->where('id', $tenant->id)->first()->id)->toBe($tenant->id); + expect(Tenant::withoutPending()->where('id', 'nonexistent-id')->first())->toBeNull(); + expect(Tenant::withoutPending()->where('id', $pendingTenant->id)->first())->toBeNull(); +}); + test('pending tenants are included in all queries based on the include_in_queries config', function () { Tenant::createPending();