Skip to content

Commit 6342231

Browse files
committed
passing tests
1 parent 6c389df commit 6342231

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/FeaturesTest.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
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+
1519
it('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

2024
it('feature is not enabled if state is off', function () {
@@ -23,8 +27,8 @@
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

3034
it('feature is enabled if restricted and closure returns true', function () {
@@ -33,14 +37,14 @@
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

4650
it('feature is not enabled if restricted and closure returns false', function () {
@@ -49,12 +53,12 @@
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

Comments
 (0)