diff --git a/src/app/Console/Commands/WalletCharge.php b/src/app/Console/Commands/WalletCharge.php --- a/src/app/Console/Commands/WalletCharge.php +++ b/src/app/Console/Commands/WalletCharge.php @@ -52,7 +52,7 @@ $wallets = Wallet::select('wallets.*') ->join('users', 'users.id', '=', 'wallets.user_id') ->whereNull('users.deleted_at') - ->get(); + ->cursor(); } foreach ($wallets as $wallet) { diff --git a/src/tests/Feature/Console/WalletChargeTest.php b/src/tests/Feature/Console/WalletChargeTest.php --- a/src/tests/Feature/Console/WalletChargeTest.php +++ b/src/tests/Feature/Console/WalletChargeTest.php @@ -117,16 +117,25 @@ $this->backdateEntitlements($user->entitlements, \Carbon\Carbon::now()->subWeeks(5)); \App\Wallet::where('balance', '<', '0')->update(['balance' => 0]); + $user2 = $this->getTestUser('wallet-charge@kolabnow.com'); + $wallet2 = $user2->wallets()->first(); + $wallet2->balance = -100; + $wallet2->save(); + Queue::fake(); // Non-existing wallet ID $this->artisan('wallet:charge')->assertExitCode(0); - Queue::assertPushed(\App\Jobs\WalletCheck::class, 1); + Queue::assertPushed(\App\Jobs\WalletCheck::class, 2); Queue::assertPushed(\App\Jobs\WalletCheck::class, function ($job) use ($wallet) { $job_wallet = TestCase::getObjectProperty($job, 'wallet'); return $job_wallet->id === $wallet->id; }); + Queue::assertPushed(\App\Jobs\WalletCheck::class, function ($job) use ($wallet2) { + $job_wallet = TestCase::getObjectProperty($job, 'wallet'); + return $job_wallet->id === $wallet2->id; + }); Queue::assertPushed(\App\Jobs\WalletCharge::class, 1); Queue::assertPushed(\App\Jobs\WalletCharge::class, function ($job) use ($wallet) {