Skip to content

Commit ab33924

Browse files
committed
test blade directive
1 parent 5153222 commit ab33924

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/BladeTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
});

0 commit comments

Comments
 (0)