1818 FeatureFlag::reset ();
1919});
2020
21- it ('throws an exception if calling isEnabled for a feature that does not exist ' , function () {
21+ it ('throws an exception if calling isOn for a feature that does not exist ' , function () {
2222 $ this ->expectException (MissingFeatureException::class);
2323
24- FeatureFlag::isEnabled ('some-feature ' );
24+ FeatureFlag::isOn ('some-feature ' );
2525 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBeNull ();
2626});
2727
3636 // handling...
3737 });
3838
39- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeFalse ();
39+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeFalse ();
4040 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBeNull ();
4141});
4242
43- it ('resolves isEnabled to false when the features state is "off" ' , function () {
43+ it ('resolves isOn to false when the features state is "off" ' , function () {
4444 Feature::factory ()->create ([
4545 'name ' => 'some-feature ' ,
4646 'state ' => FeatureState::off ()
4747 ]);
4848
49- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeFalse ();
49+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeFalse ();
5050 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::off ()->value );
5151});
5252
53- it ('resolves isEnabled to true when the features state is "on" ' , function () {
53+ it ('resolves isOn to true when the features state is "on" ' , function () {
5454 Feature::factory ()->create ([
5555 'name ' => 'some-feature ' ,
5656 'state ' => FeatureState::on ()
5757 ]);
5858
59- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeTrue ();
59+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeTrue ();
6060 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::on ()->value );
6161});
6262
63- it ('resolves isEnabled to true when feature state is "restricted " and the closure returns true ' , function () {
63+ it ('resolves isOn to true when feature state is "dynamic " and the closure returns true ' , function () {
6464 Feature::factory ()->create ([
6565 'name ' => 'some-feature ' ,
6666 'state ' => FeatureState::dynamic (),
7070 return true ;
7171 });
7272
73- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeTrue ();
73+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeTrue ();
7474 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::dynamic ()->value );
7575});
7676
77- it ('resolves isEnabled to false when feature state is "restricted " and the closure returns false ' , function () {
77+ it ('resolves isOn to false when feature state is "dynamic " and the closure returns false ' , function () {
7878 Feature::factory ()->create ([
7979 'name ' => 'some-feature ' ,
8080 'state ' => FeatureState::dynamic (),
8484 return false ;
8585 });
8686
87- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeFalse ();
87+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeFalse ();
8888 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::dynamic ()->value );
8989});
9090
91- it ('uses the default restricted closure if no feature specific closure has been defined ' , function () {
91+ it ('uses the default dynamic closure if no feature specific closure has been defined ' , function () {
9292 Feature::factory ()->create ([
9393 'name ' => 'some-feature ' ,
9494 'state ' => FeatureState::dynamic (),
9898 return true ;
9999 });
100100
101- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeTrue ();
101+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeTrue ();
102102 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::dynamic ()->value );
103103});
104104
105- it ('resolves isEnabled to false when feature state is "restricted " and no restricted closure has been defined ' , function () {
105+ it ('resolves isOn to false when feature state is "dynamic " and no dynamic closure has been defined ' , function () {
106106 Feature::factory ()->create ([
107107 'name ' => 'some-feature ' ,
108108 'state ' => FeatureState::dynamic (),
109109 ]);
110110
111- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeFalse ();
111+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeFalse ();
112112});
113113
114114it ('can update a features state ' , function () {
124124 FeatureFlag::updateFeatureState ('some-feature ' , FeatureState::on ());
125125
126126 Event::assertDispatched (\Codinglabs \FeatureFlags \Events \FeatureUpdatedEvent::class);
127- expect (FeatureFlag::isEnabled ('some-feature ' ))->toBeTrue ();
127+ expect (FeatureFlag::isOn ('some-feature ' ))->toBeTrue ();
128128 expect (cache ()->store ('array ' )->get ('testing.some-feature ' ))->toBe (FeatureState::on ()->value );
129129});
130+
131+ it ('uses the default cache store when cache store has not been set ' , function () {
132+ config (['cache.default ' => 'file ' ]);
133+
134+ config (['feature-flags.cache_store ' => env ('FEATURES_CACHE_STORE ' , config ('cache.default ' ))]);
135+
136+ expect (config ('feature-flags.cache_store ' ))->toBe ('file ' );
137+ });
0 commit comments