77 cache ()->flush ();
88
99 config ([
10- 'features .cache_prefix ' => 'testing ' ,
11- 'features .cache_store ' => 'array ' ,
10+ 'feature-flags .cache_prefix ' => 'testing ' ,
11+ 'feature-flags .cache_store ' => 'array ' ,
1212 ]);
1313});
1414
15+ it ('generates the correct cache key ' , function () {
16+ expect (FeatureFlags::getFeatureKey ('some-feature ' ))->toBe ('testing.some-feature ' );
17+ });
18+
1519it ('feature is not enabled if it does not exist ' , function () {
16- expect (FeatureFlags::enabled ('some-feature ' ))->toBeFalse ();
17- expect (cache ()->driver (' array ' )->get ('testing.some-feature ' ))->toBeNull ();
20+ expect (FeatureFlags::isEnabled ('some-feature ' ))->toBeFalse ();
21+ expect (cache ()->driver (config ( ' feature-flags.cache_store ' ) )->get ('testing.some-feature ' ))->toBeNull ();
1822});
1923
2024it ('feature is not enabled if state is off ' , function () {
2327 'state ' => 'off '
2428 ]);
2529
26- expect (FeatureFlags::enabled ('some-feature ' ))->toBeFalse ();
27- expect (cache ()->driver (' array ' )->get ('testing.some-feature ' ))->toBe ('off ' );
30+ expect (FeatureFlags::isEnabled ('some-feature ' ))->toBeFalse ();
31+ expect (cache ()->driver (config ( ' feature-flags.cache_store ' ) )->get ('testing.some-feature ' ))->toBe ('off ' );
2832});
2933
3034it ('feature is enabled if restricted and closure returns true ' , function () {
3337 'state ' => 'restricted '
3438 ]);
3539
36- FeatureFlags::restrictFeature ('some-feature ' , function ($ feature ) {
40+ FeatureFlags::restrictFeatureWith ('some-feature ' , function ($ feature ) {
3741 expect ($ feature )->toBe ('some-feature ' );
3842
3943 return true ;
4044 });
4145
42- expect (FeatureFlags::enabled ('some-feature ' ))->toBeTrue ();
43- expect (cache ()->driver (' array ' )->get ('testing.some-feature ' ))->toBe ('restricted ' );
46+ expect (FeatureFlags::isEnabled ('some-feature ' ))->toBeTrue ();
47+ expect (cache ()->driver (config ( ' feature-flags.cache_store ' ) )->get ('testing.some-feature ' ))->toBe ('restricted ' );
4448});
4549
4650it ('feature is not enabled if restricted and closure returns false ' , function () {
4953 'state ' => 'restricted '
5054 ]);
5155
52- FeatureFlags::restrictFeature ('some-feature ' , function ($ feature ) {
56+ FeatureFlags::restrictFeatureWith ('some-feature ' , function ($ feature ) {
5357 expect ($ feature )->toBe ('some-feature ' );
5458
5559 return false ;
5660 });
5761
58- expect (FeatureFlags::enabled ('some-feature ' ))->toBeFalse ();
59- expect (cache ()->driver (' array ' )->get ('testing.some-feature ' ))->toBe ('restricted ' );
62+ expect (FeatureFlags::isEnabled ('some-feature ' ))->toBeFalse ();
63+ expect (cache ()->driver (config ( ' feature-flags.cache_store ' ) )->get ('testing.some-feature ' ))->toBe ('restricted ' );
6064});
0 commit comments