|
2 | 2 | use CodeB\FeatureFlags\Flag; |
3 | 3 | use Yoast\WPTestUtils\WPIntegration\TestCase; |
4 | 4 |
|
5 | | -class FlagTest extends TestCase{ |
| 5 | +class FlagTest extends TestCase { |
6 | 6 |
|
7 | 7 | public function test_is_enabled_returns_true_if_flags_exists_and_enabled(): void { |
8 | 8 | // Set up test data |
9 | | - $optionValue = [['id' => 1, 'name' => 'test', 'enabled' => true ]]; |
10 | | - update_option(Flag::$option_name, $optionValue); |
11 | | - |
12 | | - $result = Flag::is_enabled('test'); |
13 | | - |
14 | | - $this->assertTrue($result); |
| 9 | + $option_value = [ |
| 10 | + [ |
| 11 | + 'id' => 1, |
| 12 | + 'name' => 'test', |
| 13 | + 'enabled' => true, |
| 14 | + ], |
| 15 | + ]; |
| 16 | + update_option( Flag::$option_name, $option_value ); |
| 17 | + |
| 18 | + $result = Flag::is_enabled( 'test' ); |
| 19 | + |
| 20 | + $this->assertTrue( $result ); |
15 | 21 | } |
16 | 22 |
|
17 | 23 | public function test_is_enabled_returns_false_if_flags_exists_and_disabled(): void { |
18 | 24 | // Set up test data |
19 | | - $optionValue = [['id' => 1, 'name' => 'test', 'enabled' => false ]]; |
20 | | - update_option(Flag::$option_name, $optionValue); |
21 | | - |
22 | | - $result = Flag::is_enabled('test'); |
23 | | - |
24 | | - $this->assertFalse($result); |
| 25 | + $option_value = [ |
| 26 | + [ |
| 27 | + 'id' => 1, |
| 28 | + 'name' => 'test', |
| 29 | + 'enabled' => false, |
| 30 | + ], |
| 31 | + ]; |
| 32 | + update_option( Flag::$option_name, $option_value ); |
| 33 | + |
| 34 | + $result = Flag::is_enabled( 'test' ); |
| 35 | + |
| 36 | + $this->assertFalse( $result ); |
25 | 37 | } |
26 | 38 |
|
27 | 39 | public function test_is_enabled_returns_false_if_flags_not_exists(): void { |
28 | 40 | // Set up test data |
29 | | - $optionValue = [['id' => 1, 'name' => 'test2', 'enabled' => true ]]; |
30 | | - update_option(Flag::$option_name, $optionValue); |
31 | | - |
32 | | - $result = Flag::is_enabled('test'); |
33 | | - |
34 | | - $this->assertFalse($result); |
| 41 | + $option_value = [ |
| 42 | + [ |
| 43 | + 'id' => 1, |
| 44 | + 'name' => 'test2', |
| 45 | + 'enabled' => true, |
| 46 | + ], |
| 47 | + ]; |
| 48 | + update_option( Flag::$option_name, $option_value ); |
| 49 | + |
| 50 | + $result = Flag::is_enabled( 'test' ); |
| 51 | + |
| 52 | + $this->assertFalse( $result ); |
35 | 53 | } |
36 | 54 |
|
37 | 55 | public function test_is_enabled_returns_false_if_option_is_empty(): void { |
38 | 56 | // Set up test data |
39 | | - $optionValue = []; |
40 | | - update_option(Flag::$option_name, $optionValue); |
| 57 | + $option_value = []; |
| 58 | + update_option( Flag::$option_name, $option_value ); |
41 | 59 |
|
42 | | - $result = Flag::is_enabled('test'); |
| 60 | + $result = Flag::is_enabled( 'test' ); |
43 | 61 |
|
44 | | - $this->assertFalse($result); |
| 62 | + $this->assertFalse( $result ); |
45 | 63 | } |
46 | 64 |
|
47 | 65 | public function test_is_enabled_returns_false_if_option_not_exists(): void { |
48 | 66 |
|
49 | | - $result = Flag::is_enabled('test'); |
| 67 | + $result = Flag::is_enabled( 'test' ); |
50 | 68 |
|
51 | | - $this->assertFalse($result); |
| 69 | + $this->assertFalse( $result ); |
52 | 70 | } |
53 | 71 | } |
0 commit comments