PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / trunk
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode vtrunk
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / tests / integration / abilities / Test_Get_Status_Ability.php
cookiebot / tests / integration / abilities Last commit date
Test_Ability_Audit_Logger.php 1 month ago Test_Cookiebot_Abilities_Registrar.php 1 month ago Test_Get_Compliance_Summary_Ability.php 1 month ago Test_Get_Status_Ability.php 1 month ago Test_Install_Ppg_Ability.php 1 month ago Test_Set_Cbid_Ability.php 1 month ago Test_Toggle_Gcm_Ability.php 1 month ago Test_Verify_Setup_Ability.php 1 month ago
Test_Get_Status_Ability.php
130 lines
1 <?php
2 /**
3 * Tests for Get_Status_Ability.
4 *
5 * @package cookiebot
6 * @subpackage tests
7 */
8
9 namespace cybot\cookiebot\tests\integration\abilities;
10
11 use cybot\cookiebot\abilities\Get_Status_Ability;
12 use WP_UnitTestCase;
13
14 /**
15 * Test class for Get_Status_Ability.
16 *
17 * @since 4.8.0
18 */
19 class Test_Get_Status_Ability extends WP_UnitTestCase {
20
21 /**
22 * Set up test fixtures.
23 *
24 * @return void
25 */
26 public function set_up() {
27 parent::set_up();
28 update_option( 'cookiebot-cbid', 'aabbccdd-1111-2222-3333-aabbccddeeff' );
29 update_option( 'cookiebot-gcm', '1' );
30 update_option( 'cookiebot-cookie-blocking-mode', 'auto' );
31 update_option( 'cookiebot-banner-enabled', '1' );
32 }
33
34 /**
35 * Test get_name returns correct ability name.
36 *
37 * @return void
38 */
39 public function test_get_name() {
40 $this->assertSame( 'cookiebot/get-status', ( new Get_Status_Ability() )->get_name() );
41 }
42
43 /**
44 * Test output has all required keys.
45 *
46 * @return void
47 */
48 public function test_output_has_all_required_keys() {
49 $args = ( new Get_Status_Ability() )->get_args();
50 $result = call_user_func( $args['execute_callback'] );
51 foreach ( array( 'cbid_set', 'gcm_enabled', 'blocking_mode', 'banner_enabled', 'plugin_version' ) as $key ) {
52 $this->assertArrayHasKey( $key, $result );
53 }
54 }
55
56 /**
57 * Test cbid_set is true when configured.
58 *
59 * @return void
60 */
61 public function test_cbid_set_true_when_configured() {
62 $args = ( new Get_Status_Ability() )->get_args();
63 $result = call_user_func( $args['execute_callback'] );
64 $this->assertTrue( $result['cbid_set'] );
65 }
66
67 /**
68 * Test cbid_set is false when empty.
69 *
70 * @return void
71 */
72 public function test_cbid_set_false_when_empty() {
73 update_option( 'cookiebot-cbid', '' );
74 $args = ( new Get_Status_Ability() )->get_args();
75 $result = call_user_func( $args['execute_callback'] );
76 $this->assertFalse( $result['cbid_set'] );
77 }
78
79 /**
80 * Test gcm_enabled reflects option.
81 *
82 * @return void
83 */
84 public function test_gcm_enabled_reflects_option() {
85 $args = ( new Get_Status_Ability() )->get_args();
86 $result = call_user_func( $args['execute_callback'] );
87 $this->assertTrue( $result['gcm_enabled'] );
88
89 update_option( 'cookiebot-gcm', '0' );
90 $result = call_user_func( $args['execute_callback'] );
91 $this->assertFalse( $result['gcm_enabled'] );
92 }
93
94 /**
95 * Test blocking_mode reflects option.
96 *
97 * @return void
98 */
99 public function test_blocking_mode_reflects_option() {
100 $args = ( new Get_Status_Ability() )->get_args();
101 $result = call_user_func( $args['execute_callback'] );
102 $this->assertSame( 'auto', $result['blocking_mode'] );
103 }
104
105 /**
106 * Test banner_enabled reflects option.
107 *
108 * @return void
109 */
110 public function test_banner_enabled_reflects_option() {
111 $args = ( new Get_Status_Ability() )->get_args();
112 $result = call_user_func( $args['execute_callback'] );
113 $this->assertTrue( $result['banner_enabled'] );
114
115 update_option( 'cookiebot-banner-enabled', '0' );
116 $result = call_user_func( $args['execute_callback'] );
117 $this->assertFalse( $result['banner_enabled'] );
118 }
119
120 /**
121 * Test show_in_rest is true.
122 *
123 * @return void
124 */
125 public function test_show_in_rest_true() {
126 $args = ( new Get_Status_Ability() )->get_args();
127 $this->assertTrue( $args['meta']['show_in_rest'] );
128 }
129 }
130