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_Compliance_Summary_Ability.php
cookiebot / tests / integration / abilities Last commit date
Test_Ability_Audit_Logger.php 2 months ago Test_Cookiebot_Abilities_Registrar.php 2 months ago Test_Get_Compliance_Summary_Ability.php 2 months ago Test_Get_Status_Ability.php 2 months ago Test_Install_Ppg_Ability.php 2 months ago Test_Set_Cbid_Ability.php 2 months ago Test_Toggle_Gcm_Ability.php 2 months ago Test_Verify_Setup_Ability.php 2 months ago
Test_Get_Compliance_Summary_Ability.php
137 lines
1 <?php
2 /**
3 * Tests for Get_Compliance_Summary_Ability.
4 *
5 * @package cookiebot
6 * @subpackage tests
7 */
8
9 namespace cybot\cookiebot\tests\integration\abilities;
10
11 use cybot\cookiebot\abilities\Get_Compliance_Summary_Ability;
12 use WP_UnitTestCase;
13
14 /**
15 * Test class for Get_Compliance_Summary_Ability.
16 *
17 * @since 4.8.0
18 */
19 class Test_Get_Compliance_Summary_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-scan-status', 'completed' );
29 update_option( 'cookiebot-user-data', '' );
30 update_option( 'cookiebot-cbid', '' );
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/get-compliance-summary', ( new Get_Compliance_Summary_Ability() )->get_name() );
40 }
41
42 /**
43 * Test output has all required keys.
44 *
45 * @return void
46 */
47 public function test_output_has_all_required_keys() {
48 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
49 $result = call_user_func( $args['execute_callback'] );
50 foreach ( array( 'regulations_covered', 'scan_status', 'consent_log_available', 'plan_type' ) as $key ) {
51 $this->assertArrayHasKey( $key, $result );
52 }
53 }
54
55 /**
56 * Test regulations_covered includes key standards.
57 *
58 * @return void
59 */
60 public function test_regulations_covered_includes_key_standards() {
61 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
62 $result = call_user_func( $args['execute_callback'] );
63 foreach ( array( 'GDPR', 'CCPA/CPRA', 'LGPD', 'IAB TCF 2.2', 'Google Consent Mode v2' ) as $reg ) {
64 $this->assertContains( $reg, $result['regulations_covered'] );
65 }
66 }
67
68 /**
69 * Test scan_status reflects option.
70 *
71 * @return void
72 */
73 public function test_scan_status_reflects_option() {
74 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
75 $result = call_user_func( $args['execute_callback'] );
76 $this->assertSame( 'completed', $result['scan_status'] );
77 }
78
79 /**
80 * Test consent_log_available is true when CBID is set.
81 *
82 * @return void
83 */
84 public function test_consent_log_available_true_when_cbid_set() {
85 update_option( 'cookiebot-cbid', 'aabbccdd-1111-2222-3333-aabbccddeeff' );
86 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
87 $result = call_user_func( $args['execute_callback'] );
88 $this->assertTrue( $result['consent_log_available'] );
89 }
90
91 /**
92 * Test consent_log_available is false when CBID is empty.
93 *
94 * @return void
95 */
96 public function test_consent_log_available_false_when_cbid_empty() {
97 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
98 $result = call_user_func( $args['execute_callback'] );
99 $this->assertFalse( $result['consent_log_available'] );
100 }
101
102 /**
103 * Test plan_type is unknown with no user data.
104 *
105 * @return void
106 */
107 public function test_plan_type_unknown_with_no_user_data() {
108 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
109 $result = call_user_func( $args['execute_callback'] );
110 $this->assertSame( 'unknown', $result['plan_type'] );
111 }
112
113 /**
114 * Test plan_type detects free plan.
115 *
116 * @return void
117 */
118 public function test_plan_type_free_detected() {
119 update_option( 'cookiebot-user-data', json_encode( array( 'subscription' => array( 'plan' => 'Free Plan' ) ) ) );
120 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
121 $result = call_user_func( $args['execute_callback'] );
122 $this->assertSame( 'free', $result['plan_type'] );
123 }
124
125 /**
126 * Test plan_type detects premium plan.
127 *
128 * @return void
129 */
130 public function test_plan_type_premium_detected() {
131 update_option( 'cookiebot-user-data', json_encode( array( 'subscription' => array( 'plan' => 'Premium' ) ) ) );
132 $args = ( new Get_Compliance_Summary_Ability() )->get_args();
133 $result = call_user_func( $args['execute_callback'] );
134 $this->assertSame( 'premium', $result['plan_type'] );
135 }
136 }
137