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 20
20
"require-dev" : {
21
21
"illuminate/container" : " ^5.3|^5.4" ,
22
22
"mockery/mockery" : " ^0.9.9" ,
23
+ "orchestra/testbench" : " ^3.4" ,
23
24
"phpunit/phpunit" : " ^6.0" ,
24
25
"satooshi/php-coveralls" : " ^1.0" ,
25
26
"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
37
37
*/
38
38
public function __construct (Rollout $ rollout )
39
39
{
40
+ parent ::__construct ();
40
41
$ this ->rollout = $ rollout ;
41
42
}
42
43
Original file line number Diff line number Diff line change 5
5
use Opensoft \Rollout \Rollout ;
6
6
use Jaspaul \LaravelRollout \Drivers \Cache ;
7
7
use Jaspaul \LaravelRollout \Console \ListCommand ;
8
+ use Jaspaul \LaravelRollout \Console \CreateCommand ;
8
9
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
9
10
10
11
class ServiceProvider extends IlluminateServiceProvider
@@ -20,6 +21,9 @@ public function boot()
20
21
return new Rollout (new Cache ($ app ->make ('cache.store ' )));
21
22
});
22
23
23
- $ this ->commands ([ListCommand::class]);
24
+ $ this ->commands ([
25
+ CreateCommand::class,
26
+ ListCommand::class
27
+ ]);
24
28
}
25
29
}
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 8
8
use Illuminate \Contracts \Cache \Repository ;
9
9
use Jaspaul \LaravelRollout \ServiceProvider ;
10
10
use Jaspaul \LaravelRollout \Console \ListCommand ;
11
+ use Jaspaul \LaravelRollout \Console \CreateCommand ;
11
12
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
12
13
13
14
class ServiceProviderTest extends TestCase
@@ -60,7 +61,10 @@ function booting_registers_our_commands()
60
61
$ serviceProvider = new TestServiceProvider ($ this ->container );
61
62
$ serviceProvider ->boot ();
62
63
63
- $ this ->assertEquals ([ListCommand::class], $ serviceProvider ->commands );
64
+ $ this ->assertEquals (
65
+ [CreateCommand::class, ListCommand::class],
66
+ $ serviceProvider ->commands
67
+ );
64
68
}
65
69
}
66
70
Original file line number Diff line number Diff line change 3
3
namespace Tests ;
4
4
5
5
use Mockery ;
6
- use PHPUnit \Framework \TestCase as Base ;
6
+ use Orchestra \Testbench \TestCase as Base ;
7
+ use Jaspaul \LaravelRollout \ServiceProvider ;
7
8
8
9
abstract class TestCase extends Base
9
10
{
@@ -15,4 +16,16 @@ protected function setUpMockery()
15
16
Mockery::getConfiguration ()->allowMockingNonExistentMethods (false );
16
17
Mockery::getConfiguration ()->allowMockingMethodsUnnecessarily (false );
17
18
}
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
+ }
18
31
}
You can’t perform that action at this time.
0 commit comments