File tree Expand file tree Collapse file tree 4 files changed +73
-0
lines changed
Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Jaspaul \LaravelRollout \Console ;
4+
5+ use Jaspaul \LaravelRollout \Helpers \User ;
6+
7+ class DeactivateCommand extends RolloutCommand
8+ {
9+ /**
10+ * The name and signature of the console command.
11+ *
12+ * @var string
13+ */
14+ protected $ signature = 'rollout:deactivate {feature} ' ;
15+
16+ /**
17+ * The console command description.
18+ *
19+ * @var string
20+ */
21+ protected $ description = 'Deactivates the provided feature for everyone at once. ' ;
22+
23+ /**
24+ * Deactivates the feature for everyone.
25+ *
26+ * @return void
27+ */
28+ public function handle ()
29+ {
30+ $ name = $ this ->argument ('feature ' );
31+ $ this ->rollout ->deactivate ($ name );
32+ }
33+ }
Original file line number Diff line number Diff line change 99use Jaspaul \LaravelRollout \Console \DeleteCommand ;
1010use Jaspaul \LaravelRollout \Console \AddUserCommand ;
1111use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
12+ use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
1213use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
1314use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
1415
@@ -28,6 +29,7 @@ public function boot()
2829 $ this ->commands ([
2930 AddUserCommand::class,
3031 CreateCommand::class,
32+ DeactivateCommand::class,
3133 DeleteCommand::class,
3234 EveryoneCommand::class,
3335 ListCommand::class,
Original file line number Diff line number Diff line change 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 \Helpers \User ;
9+ use Jaspaul \LaravelRollout \Drivers \Cache ;
10+
11+ class DeactivateCommandTest extends TestCase
12+ {
13+ /**
14+ * @test
15+ */
16+ function running_the_command_will_deactivate_the_feature_for_all_users ()
17+ {
18+ $ store = app ()->make ('cache.store ' )->getStore ();
19+
20+ $ rollout = app ()->make (Rollout::class);
21+ $ rollout ->activateUser ('derp ' , new User ("1 " ));
22+ $ rollout ->activatePercentage ('derp ' , 82 );
23+
24+ $ this ->assertEquals ('derp ' , $ store ->get ('rollout.feature:__features__ ' ));
25+ $ this ->assertEquals ('82|1|| ' , $ store ->get ('rollout.feature:derp ' ));
26+
27+ Artisan::call ('rollout:deactivate ' , [
28+ 'feature ' => 'derp '
29+ ]);
30+
31+ $ store = app ()->make ('cache.store ' )->getStore ();
32+
33+ $ this ->assertEquals ('derp ' , $ store ->get ('rollout.feature:__features__ ' ));
34+ $ this ->assertEquals ('0||| ' , $ store ->get ('rollout.feature:derp ' ));
35+ }
36+ }
Original file line number Diff line number Diff line change 1212use Jaspaul \LaravelRollout \Console \DeleteCommand ;
1313use Jaspaul \LaravelRollout \Console \AddUserCommand ;
1414use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
15+ use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
1516use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
1617use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
1718
@@ -69,6 +70,7 @@ function booting_registers_our_commands()
6970 [
7071 AddUserCommand::class,
7172 CreateCommand::class,
73+ DeactivateCommand::class,
7274 DeleteCommand::class,
7375 EveryoneCommand::class,
7476 ListCommand::class,
You can’t perform that action at this time.
0 commit comments