File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed
Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 1717 "opensoft/rollout" : " ^2.2"
1818 },
1919 "require-dev" : {
20+ "illuminate/container" : " ^5.3|^5.4" ,
2021 "mockery/mockery" : " ^0.9.9" ,
2122 "phpunit/phpunit" : " ^6.0" ,
2223 "satooshi/php-coveralls" : " ^1.0" ,
Original file line number Diff line number Diff line change 22
33namespace Jaspaul \LaravelRollout \Drivers ;
44
5- use Illuminate \Cache \Repository ;
65use Illuminate \Contracts \Cache \Store ;
6+ use Illuminate \Contracts \Cache \Repository ;
77use Opensoft \Rollout \Storage \StorageInterface ;
88
99class Cache implements StorageInterface
1010{
1111 /**
1212 * An instance of a cache repository that we can store our keys in.
1313 *
14- * @var \Illuminate\Cache\Repository;
14+ * @var \Illuminate\Contracts\ Cache\Repository
1515 */
1616 protected $ repository ;
1717
@@ -26,7 +26,7 @@ class Cache implements StorageInterface
2626 * Configures our cache driver with an instance of the cache repository and
2727 * a key prefix.
2828 *
29- * @param \Illuminate\Cache\Repository $repository
29+ * @param \Illuminate\Contracts\ Cache\Repository $repository
3030 * An instance of the cache repository.
3131 * @param string $prefix
3232 * A prefix for the cache keys.
Original file line number Diff line number Diff line change 22
33namespace Jaspaul \LaravelRollout ;
44
5+ use Opensoft \Rollout \Rollout ;
56use Jaspaul \LaravelRollout \Drivers \Cache ;
67use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
78
@@ -14,5 +15,8 @@ class ServiceProvider extends IlluminateServiceProvider
1415 */
1516 public function boot ()
1617 {
18+ $ this ->app ->singleton (Rollout::class, function ($ app ) {
19+ return new Rollout (new Cache ($ app ->make ('cache.store ' )));
20+ });
1721 }
1822}
Original file line number Diff line number Diff line change 33namespace Tests ;
44
55use Mockery ;
6+ use Opensoft \Rollout \Rollout ;
7+ use Illuminate \Container \Container ;
8+ use Illuminate \Contracts \Cache \Repository ;
69use Jaspaul \LaravelRollout \ServiceProvider ;
7- use Illuminate \Contracts \Container \Container ;
810use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
911
1012class ServiceProviderTest extends TestCase
@@ -17,7 +19,7 @@ class ServiceProviderTest extends TestCase
1719 */
1820 function setup_service_provider ()
1921 {
20- $ this ->container = Mockery:: mock ( Container::class );
22+ $ this ->container = Container::getInstance ( );
2123 $ this ->serviceProvider = new ServiceProvider ($ this ->container );
2224 }
2325
@@ -29,4 +31,19 @@ function ensure_a_service_provider_can_be_constructed()
2931 $ this ->assertInstanceOf (ServiceProvider::class, $ this ->serviceProvider );
3032 $ this ->assertInstanceOf (IlluminateServiceProvider::class, $ this ->serviceProvider );
3133 }
34+
35+ /**
36+ * @test
37+ */
38+ function booting_registers_a_rollout_singleton_into_the_container ()
39+ {
40+ $ this ->container ->singleton ('cache.store ' , function ($ app ) {
41+ return Mockery::mock (Repository::class);
42+ });
43+
44+ $ this ->serviceProvider ->boot ();
45+
46+ $ result = $ this ->container ->make (Rollout::class);
47+ $ this ->assertInstanceOf (Rollout::class, $ result );
48+ }
3249}
You can’t perform that action at this time.
0 commit comments