From 59591d8aecae29a763e0130639094a6ad90063e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Tue, 30 Jan 2024 20:24:21 +0100 Subject: [PATCH] updates --- composer.json | 2 +- src/Console/Commands/ClearCarts.php | 33 +++++++++++++++-------------- tests/Console/CommandsTest.php | 9 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/composer.json b/composer.json index 2feab606..b4af5f36 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "require-dev": { "fakerphp/faker": "^1.9.1", - "laravel/laravel": "^10.0", + "laravel/laravel": "^10.43", "mockery/mockery": "^1.4.4", "phpunit/phpunit": "^10.0", "laravel/pint": "^1.6", diff --git a/src/Console/Commands/ClearCarts.php b/src/Console/Commands/ClearCarts.php index 808c176b..e1f2dd34 100644 --- a/src/Console/Commands/ClearCarts.php +++ b/src/Console/Commands/ClearCarts.php @@ -26,31 +26,32 @@ class ClearCarts extends Command /** * Execute the console command. */ - public function handle(): int + public function handle(): void { if ($this->option('all')) { - Cart::proxy()->newQuery()->truncate(); - Item::query()->where('itemable_type', Cart::getProxiedClass())->delete(); - Shipping::proxy()->newQuery()->where('shippable_type', Cart::getProxiedClass())->delete(); + Cart::query()->get(); + + // Cart::proxy()->newQuery()->truncate(); + // Item::proxy()->newQuery()->where('itemable_type', Cart::getProxiedClass())->delete(); + // Shipping::proxy()->newQuery()->where('shippable_type', Cart::getProxiedClass())->delete(); $this->info('All carts have been deleted.'); } else { - Item::query() - ->where('itemable_type', Cart::getProxiedClass()) - ->whereIn('itemable_id', Cart::proxy()->newQuery()->expired()->select('id')) - ->delete(); + // Item::proxy() + // ->newQuery() + // ->where('itemable_type', Cart::getProxiedClass()) + // ->whereIn('itemable_id', Cart::proxy()->newQuery()->expired()->select('id')) + // ->delete(); - Shipping::proxy() - ->newQuery() - ->where('shippable_type', Cart::getProxiedClass()) - ->whereIn('shippable_id', Cart::proxy()->newQuery()->expired()->select('id')) - ->delete(); + // Shipping::proxy() + // ->newQuery() + // ->where('shippable_type', Cart::getProxiedClass()) + // ->whereIn('shippable_id', Cart::proxy()->newQuery()->expired()->select('id')) + // ->delete(); - Cart::proxy()->newQuery()->expired()->delete(); + // Cart::proxy()->newQuery()->expired()->delete(); $this->info('Expired carts have been deleted.'); } - - return Command::SUCCESS; } } diff --git a/tests/Console/CommandsTest.php b/tests/Console/CommandsTest.php index c9a9ea70..ed8c123a 100644 --- a/tests/Console/CommandsTest.php +++ b/tests/Console/CommandsTest.php @@ -3,7 +3,6 @@ namespace Cone\Bazar\Tests\Console; use Cone\Bazar\Tests\TestCase; -use Illuminate\Console\Command; use Illuminate\Support\Facades\Queue; class CommandsTest extends TestCase @@ -12,11 +11,11 @@ public function test_it_can_clear_carts(): void { $this->artisan('bazar:clear-carts', ['--all' => true]) ->expectsOutput('All carts have been deleted.') - ->assertExitCode(Command::SUCCESS); + ->assertSuccessful(); $this->artisan('bazar:clear-carts') ->expectsOutput('Expired carts have been deleted.') - ->assertExitCode(Command::SUCCESS); + ->assertSuccessful(); } public function test_it_can_install_bazar(): void @@ -24,9 +23,9 @@ public function test_it_can_install_bazar(): void Queue::fake(); $this->artisan('bazar:install') - ->assertExitCode(Command::SUCCESS); + ->assertSuccessful(); $this->artisan('bazar:install', ['--seed' => true]) - ->assertExitCode(Command::SUCCESS); + ->assertSuccessful(); } }