Skip to content

Commit

Permalink
Fixes purge output message when nothing is purged (#114)
Browse files Browse the repository at this point in the history
* Fixes purge output message when nothing is purged

* Fix code styling

---------

Co-authored-by: timacdonald <timacdonald@users.noreply.github.com>
  • Loading branch information
timacdonald and timacdonald authored Jul 18, 2024
1 parent 26bcd0a commit 203e40f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Commands/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ public function handle(FeatureManager $manager)

$store->purge($features);

with($features ?: ['All features'], function ($names) {
$this->components->info(implode(', ', $names).' successfully purged from storage.');
});
if ($features) {
$this->components->info(implode(', ', $features).' successfully purged from storage.');
} elseif ($except) {
$this->components->info('No features to purge from storage.');
} else {
$this->components->info('All features successfully purged from storage.');
}

return self::SUCCESS;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Feature/PurgeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ public function test_it_can_exclude_features_to_purge_from_storage()
$this->assertSame(0, DB::table('features')->count());
}

public function test_it_outputs_that_no_features_have_been_purged()
{
Feature::define('foo', true);

Feature::for('tim')->active('foo');
Feature::for('taylor')->active('foo');

$this->assertSame(2, DB::table('features')->where('name', 'foo')->count());

$this->artisan('pennant:purge --except=foo')->expectsOutputToContain('No features to purge from storage.');

$this->assertSame(2, DB::table('features')->where('name', 'foo')->count());
}

public function test_it_can_combine_except_and_features_as_arguments()
{
DB::table('features')->insert([
Expand Down

0 comments on commit 203e40f

Please sign in to comment.