Skip to content

Commit 71b0b5a

Browse files
committed
Add command to delete feature flags
1 parent a474bdf commit 71b0b5a

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

src/Console/DeleteCommand.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Jaspaul\LaravelRollout\Console;
4+
5+
class DeleteCommand extends RolloutCommand
6+
{
7+
/**
8+
* The name and signature of the console command.
9+
*
10+
* @var string
11+
*/
12+
protected $signature = 'rollout:delete {feature}';
13+
14+
/**
15+
* The console command description.
16+
*
17+
* @var string
18+
*/
19+
protected $description = 'Deletes the feature with the provided name.';
20+
21+
/**
22+
* Deletes the provided feature.
23+
*
24+
* @return void
25+
*/
26+
public function handle()
27+
{
28+
$name = $this->argument('feature');
29+
$this->rollout->remove($name);
30+
}
31+
}

src/ServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Jaspaul\LaravelRollout\Drivers\Cache;
77
use Jaspaul\LaravelRollout\Console\ListCommand;
88
use Jaspaul\LaravelRollout\Console\CreateCommand;
9+
use Jaspaul\LaravelRollout\Console\DeleteCommand;
910
use Jaspaul\LaravelRollout\Console\AddUserCommand;
1011
use Jaspaul\LaravelRollout\Console\RemoveUserCommand;
1112
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
@@ -26,6 +27,7 @@ public function boot()
2627
$this->commands([
2728
AddUserCommand::class,
2829
CreateCommand::class,
30+
DeleteCommand::class,
2931
ListCommand::class,
3032
RemoveUserCommand::class
3133
]);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Tests\Drivers;
4+
5+
use Tests\TestCase;
6+
use Opensoft\Rollout\Rollout;
7+
use Illuminate\Support\Facades\Artisan;
8+
use Jaspaul\LaravelRollout\Drivers\Cache;
9+
10+
class DeleteCommandTest extends TestCase
11+
{
12+
/**
13+
* @test
14+
*/
15+
function running_the_command_with_a_feature_will_remove_the_corresponding_feature()
16+
{
17+
$store = app()->make('cache.store')->getStore();
18+
19+
$rollout = app()->make(Rollout::class);
20+
$rollout->get('derp');
21+
22+
$this->assertEquals('derp', $store->get('rollout.feature:__features__'));
23+
24+
Artisan::call('rollout:delete', [
25+
'feature' => 'derp'
26+
]);
27+
28+
$store = app()->make('cache.store')->getStore();
29+
30+
$this->assertEquals('', $store->get('rollout.feature:__features__'));
31+
}
32+
}

tests/ServiceProviderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Jaspaul\LaravelRollout\ServiceProvider;
1010
use Jaspaul\LaravelRollout\Console\ListCommand;
1111
use Jaspaul\LaravelRollout\Console\CreateCommand;
12+
use Jaspaul\LaravelRollout\Console\DeleteCommand;
1213
use Jaspaul\LaravelRollout\Console\AddUserCommand;
1314
use Jaspaul\LaravelRollout\Console\RemoveUserCommand;
1415
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
@@ -67,6 +68,7 @@ function booting_registers_our_commands()
6768
[
6869
AddUserCommand::class,
6970
CreateCommand::class,
71+
DeleteCommand::class,
7072
ListCommand::class,
7173
RemoveUserCommand::class
7274
],

0 commit comments

Comments
 (0)