|
43 | 43 | // handling... |
44 | 44 | }); |
45 | 45 |
|
46 | | - expect(FeatureFlag::isOn('some-feature'))->toBeFalse(); |
47 | | - expect(FeatureFlag::isOff('some-feature'))->toBeTrue(); |
48 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBeNull(); |
| 46 | + expect(FeatureFlag::isOn('some-feature'))->toBeFalse() |
| 47 | + ->and(FeatureFlag::isOff('some-feature'))->toBeTrue() |
| 48 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBeNull(); |
49 | 49 | }); |
50 | 50 |
|
51 | 51 | it('resolves isOn to false when the features state is "off"', function () { |
|
54 | 54 | 'state' => FeatureState::off() |
55 | 55 | ]); |
56 | 56 |
|
57 | | - expect(FeatureFlag::isOn('some-feature'))->toBeFalse(); |
58 | | - expect(FeatureFlag::isOff('some-feature'))->toBeTrue(); |
59 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::off()->value); |
| 57 | + expect(FeatureFlag::isOn('some-feature'))->toBeFalse() |
| 58 | + ->and(FeatureFlag::isOff('some-feature'))->toBeTrue() |
| 59 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::off()->value); |
60 | 60 | }); |
61 | 61 |
|
62 | 62 | it('resolves isOn to true when the features state is "on"', function () { |
|
65 | 65 | 'state' => FeatureState::on() |
66 | 66 | ]); |
67 | 67 |
|
68 | | - expect(FeatureFlag::isOn('some-feature'))->toBeTrue(); |
69 | | - expect(FeatureFlag::isOff('some-feature'))->toBeFalse(); |
70 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::on()->value); |
| 68 | + expect(FeatureFlag::isOn('some-feature'))->toBeTrue() |
| 69 | + ->and(FeatureFlag::isOff('some-feature'))->toBeFalse() |
| 70 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::on()->value); |
71 | 71 | }); |
72 | 72 |
|
73 | 73 | it('resolves isOn to true when feature state is "dynamic" and the closure returns true', function () { |
|
80 | 80 | return true; |
81 | 81 | }); |
82 | 82 |
|
83 | | - expect(FeatureFlag::isOn('some-feature'))->toBeTrue(); |
84 | | - expect(FeatureFlag::isOff('some-feature'))->toBeFalse(); |
85 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
| 83 | + expect(FeatureFlag::isOn('some-feature'))->toBeTrue() |
| 84 | + ->and(FeatureFlag::isOff('some-feature'))->toBeFalse() |
| 85 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
86 | 86 | }); |
87 | 87 |
|
88 | 88 | it('resolves isOn to false when feature state is "dynamic" and the closure returns false', function () { |
|
95 | 95 | return false; |
96 | 96 | }); |
97 | 97 |
|
98 | | - expect(FeatureFlag::isOn('some-feature'))->toBeFalse(); |
99 | | - expect(FeatureFlag::isOff('some-feature'))->toBeTrue(); |
100 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
| 98 | + expect(FeatureFlag::isOn('some-feature'))->toBeFalse() |
| 99 | + ->and(FeatureFlag::isOff('some-feature'))->toBeTrue() |
| 100 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
101 | 101 | }); |
102 | 102 |
|
103 | 103 | it('uses the default dynamic closure if no feature specific closure has been defined', function () { |
|
110 | 110 | return true; |
111 | 111 | }); |
112 | 112 |
|
113 | | - expect(FeatureFlag::isOn('some-feature'))->toBeTrue(); |
114 | | - expect(FeatureFlag::isOff('some-feature'))->toBeFalse(); |
115 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
| 113 | + expect(FeatureFlag::isOn('some-feature'))->toBeTrue() |
| 114 | + ->and(FeatureFlag::isOff('some-feature'))->toBeFalse() |
| 115 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::dynamic()->value); |
116 | 116 | }); |
117 | 117 |
|
118 | 118 | it('resolves isOn to false when feature state is "dynamic" and no dynamic closure has been defined', function () { |
|
121 | 121 | 'state' => FeatureState::dynamic(), |
122 | 122 | ]); |
123 | 123 |
|
124 | | - expect(FeatureFlag::isOn('some-feature'))->toBeFalse(); |
125 | | - expect(FeatureFlag::isOff('some-feature'))->toBeTrue(); |
| 124 | + expect(FeatureFlag::isOn('some-feature'))->toBeFalse() |
| 125 | + ->and(FeatureFlag::isOff('some-feature'))->toBeTrue(); |
126 | 126 | }); |
127 | 127 |
|
128 | 128 | it('resolves the current state', function () { |
|
139 | 139 | 'state' => FeatureState::on() |
140 | 140 | ]); |
141 | 141 |
|
142 | | - expect(FeatureFlag::getState('some-off-feature'))->toBe(FeatureState::off()); |
143 | | - expect(FeatureFlag::getState('some-dynamic-feature'))->toBe(FeatureState::dynamic()); |
144 | | - expect(FeatureFlag::getState('some-on-feature'))->toBe(FeatureState::on()); |
| 142 | + expect(FeatureFlag::getState('some-off-feature'))->toBe(FeatureState::off()) |
| 143 | + ->and(FeatureFlag::getState('some-dynamic-feature'))->toBe(FeatureState::dynamic()) |
| 144 | + ->and(FeatureFlag::getState('some-on-feature'))->toBe(FeatureState::on()); |
145 | 145 | }); |
146 | 146 |
|
147 | 147 | it('can update a features state', function () { |
|
157 | 157 | FeatureFlag::updateFeatureState('some-feature', FeatureState::on()); |
158 | 158 |
|
159 | 159 | Event::assertDispatched(\Codinglabs\FeatureFlags\Events\FeatureUpdatedEvent::class); |
160 | | - expect(FeatureFlag::isOn('some-feature'))->toBeTrue(); |
161 | | - expect(FeatureFlag::isOff('some-feature'))->toBeFalse(); |
162 | | - expect(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::on()->value); |
| 160 | + expect(FeatureFlag::isOn('some-feature'))->toBeTrue() |
| 161 | + ->and(FeatureFlag::isOff('some-feature'))->toBeFalse() |
| 162 | + ->and(cache()->store('array')->get('testing.some-feature'))->toBe(FeatureState::on()->value); |
163 | 163 | }); |
164 | 164 |
|
165 | 165 | it('uses the default cache store when cache store has not been set', function () { |
|
0 commit comments