7
7
use Illuminate \Container \Container ;
8
8
use Illuminate \Contracts \Cache \Repository ;
9
9
use Jaspaul \LaravelRollout \ServiceProvider ;
10
+ use Illuminate \Database \ConnectionInterface ;
11
+ use Illuminate \Contracts \Encryption \Encrypter ;
10
12
use Jaspaul \LaravelRollout \Console \ListCommand ;
11
13
use Jaspaul \LaravelRollout \Console \CreateCommand ;
12
14
use Jaspaul \LaravelRollout \Console \DeleteCommand ;
13
15
use Jaspaul \LaravelRollout \Console \AddUserCommand ;
14
16
use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
17
+ use Illuminate \Contracts \Config \Repository as Config ;
15
18
use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
16
19
use Jaspaul \LaravelRollout \Console \PercentageCommand ;
17
20
use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
@@ -43,8 +46,17 @@ function ensure_a_service_provider_can_be_constructed()
43
46
/**
44
47
* @test
45
48
*/
46
- function booting_registers_a_rollout_singleton_into_the_container ()
49
+ function booting_registers_a_cache_backed_rollout_singleton_into_the_container ()
47
50
{
51
+ $ this ->container ->singleton (Config::class, function ($ app ) {
52
+ $ config = Mockery::mock (Config::class);
53
+ $ config ->shouldReceive ('get ' )
54
+ ->with ('laravel-rollout.storage ' )
55
+ ->andReturn ('cache ' );
56
+
57
+ return $ config ;
58
+ });
59
+
48
60
$ this ->container ->singleton ('cache.store ' , function ($ app ) {
49
61
return Mockery::mock (Repository::class);
50
62
});
@@ -58,12 +70,40 @@ function booting_registers_a_rollout_singleton_into_the_container()
58
70
/**
59
71
* @test
60
72
*/
61
- function booting_registers_our_commands ()
73
+ function booting_registers_a_database_backed_rollout_singleton_into_the_container ()
62
74
{
63
- $ this ->container ->singleton ('cache.store ' , function ($ app ) {
64
- return Mockery::mock (Repository::class);
75
+ $ this ->container ->singleton (Config::class, function ($ app ) {
76
+ $ config = Mockery::mock (Config::class);
77
+ $ config ->shouldReceive ('get ' )
78
+ ->with ('laravel-rollout.storage ' )
79
+ ->andReturn ('database ' );
80
+
81
+ $ config ->shouldReceive ('get ' )
82
+ ->with ('laravel-rollout.table ' )
83
+ ->andReturn ('rollout ' );
84
+
85
+ return $ config ;
86
+ });
87
+
88
+ $ this ->container ->singleton (ConnectionInterface::class, function ($ app ) {
89
+ return Mockery::mock (ConnectionInterface::class);
90
+ });
91
+
92
+ $ this ->container ->singleton (Encrypter::class, function ($ app ) {
93
+ return Mockery::mock (Encrypter::class);
65
94
});
66
95
96
+ $ this ->serviceProvider ->boot ();
97
+
98
+ $ result = $ this ->container ->make (Rollout::class);
99
+ $ this ->assertInstanceOf (Rollout::class, $ result );
100
+ }
101
+
102
+ /**
103
+ * @test
104
+ */
105
+ function booting_registers_our_commands ()
106
+ {
67
107
$ serviceProvider = new TestServiceProvider ($ this ->container );
68
108
$ serviceProvider ->boot ();
69
109
0 commit comments