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 17
17
"opensoft/rollout" : " ^2.2"
18
18
},
19
19
"require-dev" : {
20
+ "illuminate/container" : " ^5.3|^5.4" ,
20
21
"mockery/mockery" : " ^0.9.9" ,
21
22
"phpunit/phpunit" : " ^6.0" ,
22
23
"satooshi/php-coveralls" : " ^1.0" ,
Original file line number Diff line number Diff line change 2
2
3
3
namespace Jaspaul \LaravelRollout \Drivers ;
4
4
5
- use Illuminate \Cache \Repository ;
6
5
use Illuminate \Contracts \Cache \Store ;
6
+ use Illuminate \Contracts \Cache \Repository ;
7
7
use Opensoft \Rollout \Storage \StorageInterface ;
8
8
9
9
class Cache implements StorageInterface
10
10
{
11
11
/**
12
12
* An instance of a cache repository that we can store our keys in.
13
13
*
14
- * @var \Illuminate\Cache\Repository;
14
+ * @var \Illuminate\Contracts\ Cache\Repository
15
15
*/
16
16
protected $ repository ;
17
17
@@ -26,7 +26,7 @@ class Cache implements StorageInterface
26
26
* Configures our cache driver with an instance of the cache repository and
27
27
* a key prefix.
28
28
*
29
- * @param \Illuminate\Cache\Repository $repository
29
+ * @param \Illuminate\Contracts\ Cache\Repository $repository
30
30
* An instance of the cache repository.
31
31
* @param string $prefix
32
32
* A prefix for the cache keys.
Original file line number Diff line number Diff line change 2
2
3
3
namespace Jaspaul \LaravelRollout ;
4
4
5
+ use Opensoft \Rollout \Rollout ;
5
6
use Jaspaul \LaravelRollout \Drivers \Cache ;
6
7
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
7
8
@@ -14,5 +15,8 @@ class ServiceProvider extends IlluminateServiceProvider
14
15
*/
15
16
public function boot ()
16
17
{
18
+ $ this ->app ->singleton (Rollout::class, function ($ app ) {
19
+ return new Rollout (new Cache ($ app ->make ('cache.store ' )));
20
+ });
17
21
}
18
22
}
Original file line number Diff line number Diff line change 3
3
namespace Tests ;
4
4
5
5
use Mockery ;
6
+ use Opensoft \Rollout \Rollout ;
7
+ use Illuminate \Container \Container ;
8
+ use Illuminate \Contracts \Cache \Repository ;
6
9
use Jaspaul \LaravelRollout \ServiceProvider ;
7
- use Illuminate \Contracts \Container \Container ;
8
10
use Illuminate \Support \ServiceProvider as IlluminateServiceProvider ;
9
11
10
12
class ServiceProviderTest extends TestCase
@@ -17,7 +19,7 @@ class ServiceProviderTest extends TestCase
17
19
*/
18
20
function setup_service_provider ()
19
21
{
20
- $ this ->container = Mockery:: mock ( Container::class );
22
+ $ this ->container = Container::getInstance ( );
21
23
$ this ->serviceProvider = new ServiceProvider ($ this ->container );
22
24
}
23
25
@@ -29,4 +31,19 @@ function ensure_a_service_provider_can_be_constructed()
29
31
$ this ->assertInstanceOf (ServiceProvider::class, $ this ->serviceProvider );
30
32
$ this ->assertInstanceOf (IlluminateServiceProvider::class, $ this ->serviceProvider );
31
33
}
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
+ }
32
49
}
You can’t perform that action at this time.
0 commit comments