PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.7.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.7.1
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_Verify_Setup_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_Verify_Setup_Ability.php
133 lines
1 <?php
2 /**
3 * Tests for Verify_Setup_Ability.
4 *
5 * @package cookiebot
6 * @subpackage tests
7 */
8
9 namespace cybot\cookiebot\tests\integration\abilities;
10
11 use cybot\cookiebot\abilities\Verify_Setup_Ability;
12 use WP_UnitTestCase;
13
14 /**
15 * Test class for Verify_Setup_Ability.
16 *
17 * @since 4.8.0
18 */
19 class Test_Verify_Setup_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 }
32
33 /**
34 * Test get_name returns correct ability name.
35 *
36 * @return void
37 */
38 public function test_get_name() {
39 $this->assertSame( 'cookiebot/verify-setup', ( new Verify_Setup_Ability() )->get_name() );
40 }
41
42 /**
43 * Test no issues when fully configured.
44 *
45 * @return void
46 */
47 public function test_no_issues_when_fully_configured() {
48 $args = ( new Verify_Setup_Ability() )->get_args();
49 $result = call_user_func( $args['execute_callback'] );
50 $this->assertEmpty( $result['issues'] );
51 $this->assertTrue( $result['cbid_configured'] );
52 $this->assertTrue( $result['gcm_enabled'] );
53 $this->assertTrue( $result['blocking_mode_automatic'] );
54 }
55
56 /**
57 * Test issue when CBID is missing.
58 *
59 * @return void
60 */
61 public function test_issue_when_cbid_missing() {
62 update_option( 'cookiebot-cbid', '' );
63 delete_site_option( 'cookiebot-cbid' );
64 $args = ( new Verify_Setup_Ability() )->get_args();
65 $result = call_user_func( $args['execute_callback'] );
66 $this->assertFalse( $result['cbid_configured'] );
67 $this->assertNotEmpty( $result['issues'] );
68 $this->assertStringContainsString( 'Domain Group ID', implode( ' ', $result['issues'] ) );
69 }
70
71 /**
72 * Test issue when blocking mode is manual.
73 *
74 * @return void
75 */
76 public function test_issue_when_blocking_mode_manual() {
77 update_option( 'cookiebot-cookie-blocking-mode', 'manual' );
78 $args = ( new Verify_Setup_Ability() )->get_args();
79 $result = call_user_func( $args['execute_callback'] );
80 $this->assertFalse( $result['blocking_mode_automatic'] );
81 $this->assertNotEmpty( $result['issues'] );
82 }
83
84 /**
85 * Test output has all required keys.
86 *
87 * @return void
88 */
89 public function test_output_has_all_required_keys() {
90 $args = ( new Verify_Setup_Ability() )->get_args();
91 $result = call_user_func( $args['execute_callback'] );
92 foreach ( array( 'cbid_configured', 'configured_domain', 'gcm_enabled', 'blocking_mode_automatic', 'issues' ) as $key ) {
93 $this->assertArrayHasKey( $key, $result );
94 }
95 }
96
97 /**
98 * Test configured_domain is a string.
99 *
100 * @return void
101 */
102 public function test_configured_domain_is_string() {
103 $args = ( new Verify_Setup_Ability() )->get_args();
104 $result = call_user_func( $args['execute_callback'] );
105 $this->assertIsString( $result['configured_domain'] );
106 $this->assertNotEmpty( $result['configured_domain'] );
107 }
108
109 /**
110 * Test issue when GCM is disabled.
111 *
112 * @return void
113 */
114 public function test_issue_when_gcm_disabled() {
115 update_option( 'cookiebot-gcm', '0' );
116 $args = ( new Verify_Setup_Ability() )->get_args();
117 $result = call_user_func( $args['execute_callback'] );
118 $this->assertFalse( $result['gcm_enabled'] );
119 $this->assertNotEmpty( $result['issues'] );
120 $this->assertStringContainsString( 'Google Consent Mode', implode( ' ', $result['issues'] ) );
121 }
122
123 /**
124 * Test show_in_rest is true.
125 *
126 * @return void
127 */
128 public function test_show_in_rest_true() {
129 $args = ( new Verify_Setup_Ability() )->get_args();
130 $this->assertTrue( $args['meta']['show_in_rest'] );
131 }
132 }
133