File tree Expand file tree Collapse file tree 7 files changed +115
-3
lines changed
Expand file tree Collapse file tree 7 files changed +115
-3
lines changed Original file line number Diff line number Diff line change 2020 "require-dev" : {
2121 "illuminate/container" : " ^5.3|^5.4" ,
2222 "mockery/mockery" : " ^0.9.9" ,
23+ "orchestra/testbench" : " ^3.4" ,
2324 "phpunit/phpunit" : " ^6.0" ,
2425 "satooshi/php-coveralls" : " ^1.0" ,
2526 "squizlabs/php_codesniffer" : " ^2.8"
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Jaspaul \LaravelRollout \Console ;
4+
5+ use Opensoft \Rollout \Rollout ;
6+ use Illuminate \Console \Command ;
7+
8+ class CreateCommand extends Command
9+ {
10+ /**
11+ * The name and signature of the console command.
12+ *
13+ * @var string
14+ */
15+ protected $ signature = 'rollout:create {feature} ' ;
16+
17+ /**
18+ * The console command description.
19+ *
20+ * @var string
21+ */
22+ protected $ description = 'Creates a feature with the provided name. ' ;
23+
24+ /**
25+ * The rollout service.
26+ *
27+ * @var \Opensoft\Rollout\Rollout
28+ */
29+ protected $ rollout ;
30+
31+ /**
32+ * Initialize our create feature command with an instance of the rollout
33+ * service.
34+ *
35+ * @param \Opensoft\Rollout\Rollout $rollout
36+ * The rollout service.
37+ */
38+ public function __construct (Rollout $ rollout )
39+ {
40+ parent ::__construct ();
41+ $ this ->rollout = $ rollout ;
42+ }
43+
44+ /**
45+ * Creates the provided feature.
46+ *
47+ * @return void
48+ */
49+ public function handle ()
50+ {
51+ $ name = $ this ->argument ('feature ' );
52+ $ this ->rollout ->get ($ name );
53+ }
54+ }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class ListCommand extends Command
3737 */
3838 public function __construct (Rollout $ rollout )
3939 {
40+ parent ::__construct ();
4041 $ this ->rollout = $ rollout ;
4142 }
4243
Original file line number Diff line number Diff line change 55use Opensoft \Rollout \Rollout ;
66use Jaspaul \LaravelRollout \Drivers \Cache ;
77use Jaspaul \LaravelRollout \Console \ListCommand ;
8+ use Jaspaul \LaravelRollout \Console \CreateCommand ;
89use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
910
1011class ServiceProvider extends IlluminateServiceProvider
@@ -20,6 +21,9 @@ public function boot()
2021 return new Rollout (new Cache ($ app ->make ('cache.store ' )));
2122 });
2223
23- $ this ->commands ([ListCommand::class]);
24+ $ this ->commands ([
25+ CreateCommand::class,
26+ ListCommand::class
27+ ]);
2428 }
2529}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Drivers ;
4+
5+ use Mockery ;
6+ use Tests \TestCase ;
7+ use Opensoft \Rollout \Rollout ;
8+ use Illuminate \Cache \ArrayStore ;
9+ use Illuminate \Cache \Repository ;
10+ use Illuminate \Support \Facades \Artisan ;
11+ use Jaspaul \LaravelRollout \Drivers \Cache ;
12+ use Symfony \Component \Console \Input \Input ;
13+ use Symfony \Component \Console \Output \Output ;
14+ use Jaspaul \LaravelRollout \Console \CreateCommand ;
15+ use Symfony \Component \Console \Input \InputInterface ;
16+ use Symfony \Component \Console \Output \OutputInterface ;
17+ use Symfony \Component \Console \Formatter \OutputFormatterInterface ;
18+
19+ class CreateCommandTest extends TestCase
20+ {
21+ /**
22+ * @test
23+ */
24+ function running_the_command_with_a_feature_will_create_the_corresponding_feature ()
25+ {
26+ Artisan::call ('rollout:create ' , [
27+ 'feature ' => 'derp '
28+ ]);
29+
30+ $ store = app ()->make ('cache.store ' )->getStore ();
31+
32+ $ this ->assertEquals ('derp ' , $ store ->get ('rollout.feature:__features__ ' ));
33+ $ this ->assertEquals ('0||| ' , $ store ->get ('rollout.feature:derp ' ));
34+ }
35+ }
Original file line number Diff line number Diff line change 88use Illuminate \Contracts \Cache \Repository ;
99use Jaspaul \LaravelRollout \ServiceProvider ;
1010use Jaspaul \LaravelRollout \Console \ListCommand ;
11+ use Jaspaul \LaravelRollout \Console \CreateCommand ;
1112use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
1213
1314class ServiceProviderTest extends TestCase
@@ -60,7 +61,10 @@ function booting_registers_our_commands()
6061 $ serviceProvider = new TestServiceProvider ($ this ->container );
6162 $ serviceProvider ->boot ();
6263
63- $ this ->assertEquals ([ListCommand::class], $ serviceProvider ->commands );
64+ $ this ->assertEquals (
65+ [CreateCommand::class, ListCommand::class],
66+ $ serviceProvider ->commands
67+ );
6468 }
6569}
6670
Original file line number Diff line number Diff line change 33namespace Tests ;
44
55use Mockery ;
6- use PHPUnit \Framework \TestCase as Base ;
6+ use Orchestra \Testbench \TestCase as Base ;
7+ use Jaspaul \LaravelRollout \ServiceProvider ;
78
89abstract class TestCase extends Base
910{
@@ -15,4 +16,16 @@ protected function setUpMockery()
1516 Mockery::getConfiguration ()->allowMockingNonExistentMethods (false );
1617 Mockery::getConfiguration ()->allowMockingMethodsUnnecessarily (false );
1718 }
19+
20+ /**
21+ * @param \Illuminate\Foundation\Application $app
22+ *
23+ * @return array
24+ */
25+ protected function getPackageProviders ($ app )
26+ {
27+ return [
28+ ServiceProvider::class,
29+ ];
30+ }
1831}
You can’t perform that action at this time.
0 commit comments