File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed
Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Jaspaul \LaravelRollout \Console ;
4+
5+ class PercentageCommand extends RolloutCommand
6+ {
7+ /**
8+ * The name and signature of the console command.
9+ *
10+ * @var string
11+ */
12+ protected $ signature = 'rollout:percentage {feature} {percentage} ' ;
13+
14+ /**
15+ * The console command description.
16+ *
17+ * @var string
18+ */
19+ protected $ description = 'Rolls out the feature to the provided percentage of users. ' ;
20+
21+ /**
22+ * Updates the rollout percentage to the provided value.
23+ *
24+ * @return void
25+ */
26+ public function handle ()
27+ {
28+ $ name = $ this ->argument ('feature ' );
29+ $ percentage = $ this ->argument ('percentage ' );
30+
31+ $ this ->rollout ->activatePercentage ($ name , $ percentage );
32+
33+ $ this ->renderFeatureAsTable ($ name );
34+ }
35+ }
Original file line number Diff line number Diff line change 1010use Jaspaul \LaravelRollout \Console \AddUserCommand ;
1111use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
1212use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
13+ use Jaspaul \LaravelRollout \Console \PercentageCommand ;
1314use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
1415use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
1516
@@ -33,6 +34,7 @@ public function boot()
3334 DeleteCommand::class,
3435 EveryoneCommand::class,
3536 ListCommand::class,
37+ PercentageCommand::class,
3638 RemoveUserCommand::class
3739 ]);
3840 }
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 \Drivers \Cache ;
9+
10+ class PercentageCommandTest extends TestCase
11+ {
12+ /**
13+ * @test
14+ */
15+ function running_the_command_will_update_the_percentage_to_the_provided_value ()
16+ {
17+ Artisan::call ('rollout:percentage ' , [
18+ 'feature ' => 'derp ' ,
19+ 'percentage ' => 88
20+ ]);
21+
22+ $ store = app ()->make ('cache.store ' )->getStore ();
23+
24+ $ this ->assertEquals ('derp ' , $ store ->get ('rollout.feature:__features__ ' ));
25+ $ this ->assertEquals ('88||| ' , $ store ->get ('rollout.feature:derp ' ));
26+ }
27+ }
Original file line number Diff line number Diff line change 1313use Jaspaul \LaravelRollout \Console \AddUserCommand ;
1414use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
1515use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
16+ use Jaspaul \LaravelRollout \Console \PercentageCommand ;
1617use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
1718use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
1819
@@ -74,6 +75,7 @@ function booting_registers_our_commands()
7475 DeleteCommand::class,
7576 EveryoneCommand::class,
7677 ListCommand::class,
78+ PercentageCommand::class,
7779 RemoveUserCommand::class
7880 ],
7981 $ serviceProvider ->commands
You can’t perform that action at this time.
0 commit comments