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 10
10
use Jaspaul \LaravelRollout \Console \AddUserCommand ;
11
11
use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
12
12
use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
13
+ use Jaspaul \LaravelRollout \Console \PercentageCommand ;
13
14
use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
14
15
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
15
16
@@ -33,6 +34,7 @@ public function boot()
33
34
DeleteCommand::class,
34
35
EveryoneCommand::class,
35
36
ListCommand::class,
37
+ PercentageCommand::class,
36
38
RemoveUserCommand::class
37
39
]);
38
40
}
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 13
13
use Jaspaul \LaravelRollout \Console \AddUserCommand ;
14
14
use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
15
15
use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
16
+ use Jaspaul \LaravelRollout \Console \PercentageCommand ;
16
17
use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
17
18
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
18
19
@@ -74,6 +75,7 @@ function booting_registers_our_commands()
74
75
DeleteCommand::class,
75
76
EveryoneCommand::class,
76
77
ListCommand::class,
78
+ PercentageCommand::class,
77
79
RemoveUserCommand::class
78
80
],
79
81
$ serviceProvider ->commands
You can’t perform that action at this time.
0 commit comments