77use Illuminate \Container \Container ;
88use Illuminate \Contracts \Cache \Repository ;
99use Jaspaul \LaravelRollout \ServiceProvider ;
10+ use Illuminate \Database \ConnectionInterface ;
11+ use Illuminate \Contracts \Encryption \Encrypter ;
1012use Jaspaul \LaravelRollout \Console \ListCommand ;
1113use Jaspaul \LaravelRollout \Console \CreateCommand ;
1214use Jaspaul \LaravelRollout \Console \DeleteCommand ;
1315use Jaspaul \LaravelRollout \Console \AddUserCommand ;
1416use Jaspaul \LaravelRollout \Console \EveryoneCommand ;
17+ use Illuminate \Contracts \Config \Repository as Config ;
1518use Jaspaul \LaravelRollout \Console \DeactivateCommand ;
1619use Jaspaul \LaravelRollout \Console \PercentageCommand ;
1720use Jaspaul \LaravelRollout \Console \RemoveUserCommand ;
@@ -43,8 +46,17 @@ function ensure_a_service_provider_can_be_constructed()
4346 /**
4447 * @test
4548 */
46- function booting_registers_a_rollout_singleton_into_the_container ()
49+ function booting_registers_a_cache_backed_rollout_singleton_into_the_container ()
4750 {
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+
4860 $ this ->container ->singleton ('cache.store ' , function ($ app ) {
4961 return Mockery::mock (Repository::class);
5062 });
@@ -58,12 +70,40 @@ function booting_registers_a_rollout_singleton_into_the_container()
5870 /**
5971 * @test
6072 */
61- function booting_registers_our_commands ()
73+ function booting_registers_a_database_backed_rollout_singleton_into_the_container ()
6274 {
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);
6594 });
6695
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+ {
67107 $ serviceProvider = new TestServiceProvider ($ this ->container );
68108 $ serviceProvider ->boot ();
69109
0 commit comments