Skip to content

Commit

Permalink
[3.x] Improves console output (#382)
Browse files Browse the repository at this point in the history
* Improves console output

* Moves dynamic content

* Fixes tests
  • Loading branch information
nunomaduro committed Jul 25, 2022
1 parent 21676ec commit be5d1c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/PruneExpired.php
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PruneExpiredTest.php
Expand Up @@ -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']);
Expand Down Expand Up @@ -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']);
}
Expand Down

0 comments on commit be5d1c7

Please sign in to comment.