Skip to content

Commit 2378602

Browse files
committed
Add command to rollout to 100% of the users
1 parent 71b0b5a commit 2378602

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/Console/EveryoneCommand.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Jaspaul\LaravelRollout\Console;
4+
5+
use Jaspaul\LaravelRollout\Helpers\User;
6+
7+
class EveryoneCommand extends RolloutCommand
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'rollout:everyone {feature}';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Rolls out the feature to all of the users in the system.';
22+
23+
/**
24+
* Updates the feature to rollout to 100% of users!
25+
*
26+
* @return void
27+
*/
28+
public function handle()
29+
{
30+
$name = $this->argument('feature');
31+
$this->rollout->activatePercentage($name, 100);
32+
}
33+
}

src/ServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Jaspaul\LaravelRollout\Console\CreateCommand;
99
use Jaspaul\LaravelRollout\Console\DeleteCommand;
1010
use Jaspaul\LaravelRollout\Console\AddUserCommand;
11+
use Jaspaul\LaravelRollout\Console\EveryoneCommand;
1112
use Jaspaul\LaravelRollout\Console\RemoveUserCommand;
1213
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
1314

@@ -28,6 +29,7 @@ public function boot()
2829
AddUserCommand::class,
2930
CreateCommand::class,
3031
DeleteCommand::class,
32+
EveryoneCommand::class,
3133
ListCommand::class,
3234
RemoveUserCommand::class
3335
]);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 EveryoneCommandTest extends TestCase
11+
{
12+
/**
13+
* @test
14+
*/
15+
function running_the_command_with_a_feature_will_set_the_rollout_percentage_to_100()
16+
{
17+
Artisan::call('rollout:everyone', [
18+
'feature' => 'derp'
19+
]);
20+
21+
$store = app()->make('cache.store')->getStore();
22+
23+
$this->assertEquals('derp', $store->get('rollout.feature:__features__'));
24+
$this->assertEquals('100|||', $store->get('rollout.feature:derp'));
25+
}
26+
}

tests/ServiceProviderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Jaspaul\LaravelRollout\Console\CreateCommand;
1212
use Jaspaul\LaravelRollout\Console\DeleteCommand;
1313
use Jaspaul\LaravelRollout\Console\AddUserCommand;
14+
use Jaspaul\LaravelRollout\Console\EveryoneCommand;
1415
use Jaspaul\LaravelRollout\Console\RemoveUserCommand;
1516
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
1617

@@ -69,6 +70,7 @@ function booting_registers_our_commands()
6970
AddUserCommand::class,
7071
CreateCommand::class,
7172
DeleteCommand::class,
73+
EveryoneCommand::class,
7274
ListCommand::class,
7375
RemoveUserCommand::class
7476
],

0 commit comments

Comments
 (0)