From fd809bc81ad753313656777ac84e1eeae2791fe7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 22 Jul 2022 15:09:37 +0200 Subject: [PATCH] Remove withPending from runForMultiple --- src/Tenancy.php | 12 +++--------- tests/PendingTenantsTest.php | 24 ------------------------ 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/src/Tenancy.php b/src/Tenancy.php index 7c1d28b3..0278218e 100644 --- a/src/Tenancy.php +++ b/src/Tenancy.php @@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Traits\Macroable; use Stancl\Tenancy\Contracts\TenancyBootstrapper; use Stancl\Tenancy\Contracts\Tenant; -use Stancl\Tenancy\Database\Concerns\PendingScope; use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedById; class Tenancy @@ -131,15 +130,10 @@ class Tenancy * @param Tenant[]|\Traversable|string[]|null $tenants * @return void */ - public function runForMultiple($tenants, callable $callback, bool $withPending = null) + public function runForMultiple($tenants, callable $callback) { - $query = $this->model()->newQuery(); - - if (is_bool($withPending) && $this->model()::hasGlobalScope(PendingScope::class)) { - $query->withPending($withPending); - } // Convert null to all tenants - $tenants = is_null($tenants) ? $query->cursor() : $tenants; + $tenants = is_null($tenants) ? $this->model()->cursor() : $tenants; // Convert incrementing int ids to strings $tenants = is_int($tenants) ? (string) $tenants : $tenants; @@ -148,7 +142,7 @@ class Tenancy $tenants = is_string($tenants) ? [$tenants] : $tenants; // Use all tenants if $tenants is falsy - $tenants = $tenants ?: $query->cursor(); + $tenants = $tenants ?: $this->model()->cursor(); $originalTenant = $this->tenant; diff --git a/tests/PendingTenantsTest.php b/tests/PendingTenantsTest.php index 9dc5c097..ff26e9b9 100644 --- a/tests/PendingTenantsTest.php +++ b/tests/PendingTenantsTest.php @@ -169,28 +169,4 @@ class PendingTenantsTest extends TestCase Event::assertDispatched(PullingPendingTenant::class); Event::assertDispatched(PendingTenantPulled::class); } - - /** @test */ - public function tenancy_run_for_multiple_can_scope_pending_tenants() - { - config(['tenancy.pending.include_in_queries' => false]); - - Tenant::createPending(); - Tenant::create(); - - $executedCount = 0; - tenancy()->runForMultiple([], function () use (&$executedCount){ - $executedCount++; - }, false); - - self::assertEquals(1, $executedCount); - - $executedCount = 0; - - tenancy()->runForMultiple([], function () use (&$executedCount){ - $executedCount++; - }, true); - - self::assertEquals(2, $executedCount); - } }