File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 33namespace YlsIdeas \FeatureFlags \Support ;
44
55use Illuminate \Contracts \Cache \Repository ;
6+ use Psr \SimpleCache \InvalidArgumentException ;
67use YlsIdeas \FeatureFlags \Contracts \Cacheable ;
78
89/**
@@ -21,9 +22,12 @@ public function hits(string $feature): bool
2122 return $ this ->repository ->has ($ this ->generateKey ($ feature ));
2223 }
2324
25+ /**
26+ * @throws InvalidArgumentException
27+ */
2428 public function result (string $ feature ): bool
2529 {
26- return $ this ->repository ->get ($ this ->generateKey ($ feature ));
30+ return ( bool ) $ this ->repository ->get ($ this ->generateKey ($ feature ));
2731 }
2832
2933 public function store (string $ feature , ?bool $ result ): void
Original file line number Diff line number Diff line change @@ -33,6 +33,26 @@ public function test_it_hits_the_cache_correct(): void
3333 $ this ->assertTrue ($ cache ->hits ('my-feature ' ));
3434 }
3535
36+ public function test_it_retrieves_the_cache_correctly (): void
37+ {
38+ $ repository = Mockery::mock (Repository::class);
39+ $ cachable = Mockery::mock (Cacheable::class);
40+
41+ $ cachable ->shouldReceive ('generateKey ' )
42+ ->with ('my-feature ' )
43+ ->once ()
44+ ->andReturn ('key ' );
45+
46+ $ repository ->shouldReceive ('get ' )
47+ ->with ('test:key ' )
48+ ->once ()
49+ ->andReturn (null );
50+
51+ $ cache = new GatewayCache ($ repository , 'test ' , $ cachable );
52+
53+ $ this ->assertFalse ($ cache ->result ('my-feature ' ));
54+ }
55+
3656 public function test_it_stores_with_a_ttl_correctly (): void
3757 {
3858 $ repository = Mockery::mock (Repository::class);
You can’t perform that action at this time.
0 commit comments