From 52b7cf0c53534a40eb3d732b9ea411af4742bfb9 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 25 Jul 2022 10:45:15 +0100 Subject: [PATCH 1/3] Improves console output --- composer.json | 8 ++++---- src/Console/Commands/PruneExpired.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f7abbc5..33dbac5 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,10 @@ "require": { "php": "^8.0.2", "ext-json": "*", - "illuminate/console": "^9.0", - "illuminate/contracts": "^9.0", - "illuminate/database": "^9.0", - "illuminate/support": "^9.0" + "illuminate/console": "^9.21", + "illuminate/contracts": "^9.21", + "illuminate/database": "^9.21", + "illuminate/support": "^9.21" }, "require-dev": { "mockery/mockery": "^1.0", diff --git a/src/Console/Commands/PruneExpired.php b/src/Console/Commands/PruneExpired.php index 0e07bfb..189b554 100644 --- a/src/Console/Commands/PruneExpired.php +++ b/src/Console/Commands/PruneExpired.php @@ -35,12 +35,12 @@ public function handle() $model::where('created_at', '<', now()->subMinutes($expiration + ($hours * 60)))->delete(); - $this->info("Tokens expired for more than {$hours} hours pruned successfully."); + $this->components->info("Tokens expired for more than {$hours} hours pruned successfully."); return 0; } - $this->warn('Expiration value not specified in configuration file.'); + $this->components->warn('Expiration value not specified in configuration file.'); return 1; } From b95837921c9e798758c4fba782a75913f819813b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 25 Jul 2022 10:46:53 +0100 Subject: [PATCH 2/3] Moves dynamic content --- src/Console/Commands/PruneExpired.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/Commands/PruneExpired.php b/src/Console/Commands/PruneExpired.php index 189b554..b6ede50 100644 --- a/src/Console/Commands/PruneExpired.php +++ b/src/Console/Commands/PruneExpired.php @@ -35,7 +35,7 @@ public function handle() $model::where('created_at', '<', now()->subMinutes($expiration + ($hours * 60)))->delete(); - $this->components->info("Tokens expired for more than {$hours} hours pruned successfully."); + $this->components->info("Tokens expired for more than [$hours hours] pruned successfully."); return 0; } From c7a67cae47d28ddf0257ca1e67e6807caf4b2e15 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 25 Jul 2022 10:49:52 +0100 Subject: [PATCH 3/3] Fixes tests --- tests/PruneExpiredTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PruneExpiredTest.php b/tests/PruneExpiredTest.php index b28b08a..e0e09e3 100644 --- a/tests/PruneExpiredTest.php +++ b/tests/PruneExpiredTest.php @@ -60,7 +60,7 @@ public function test_can_delete_expired_tokens_with_integer_expiration() ]); $this->artisan('sanctum:prune-expired --hours=2') - ->expectsOutput('Tokens expired for more than 2 hours pruned successfully.'); + ->expectsOutputToContain('Tokens expired for more than [2 hours] pruned successfully.'); $this->assertDatabaseMissing('personal_access_tokens', ['name' => 'Test_1']); $this->assertDatabaseHas('personal_access_tokens', ['name' => 'Test_2']); @@ -89,7 +89,7 @@ public function test_cant_delete_expired_tokens_with_null_expiration() ]); $this->artisan('sanctum:prune-expired --hours=2') - ->expectsOutput('Expiration value not specified in configuration file.'); + ->expectsOutputToContain('Expiration value not specified in configuration file.'); $this->assertDatabaseHas('personal_access_tokens', ['name' => 'Test']); }