File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Codinglabs \FeatureFlags \Models \Feature ;
4+ use Codinglabs \FeatureFlags \Enums \FeatureState ;
5+ use Codinglabs \FeatureFlags \Facades \FeatureFlag ;
6+ use Illuminate \Foundation \Testing \Concerns \InteractsWithViews ;
7+
8+ uses (InteractsWithViews::class);
9+
10+ beforeEach (function () {
11+ config ([
12+ 'feature-flags.cache_store ' => 'array ' ,
13+ 'feature-flags.cache_prefix ' => 'testing ' ,
14+ ]);
15+
16+ cache ()->store ('array ' )->clear ();
17+ });
18+
19+ afterEach (function () {
20+ FeatureFlag::reset ();
21+ });
22+
23+ it ('does not reveal things when feature is off ' , function () {
24+ Feature::factory ()->create ([
25+ 'name ' => 'some-feature ' ,
26+ 'state ' => FeatureState::off ()
27+ ]);
28+
29+ $ view = $ this ->blade ("@feature('some-feature') secret things @endfeature " );
30+
31+ $ view ->assertDontSee ('secret things ' );
32+ });
33+
34+ it ('reveals things when feature is on ' , function () {
35+ Feature::factory ()->create ([
36+ 'name ' => 'some-feature ' ,
37+ 'state ' => FeatureState::on ()
38+ ]);
39+
40+ $ view = $ this ->blade ("@feature('some-feature') secret things @endfeature " );
41+
42+ $ view ->assertSee ('secret things ' );
43+ });
You can’t perform that action at this time.
0 commit comments