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_Install_Ppg_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_Install_Ppg_Ability.php
78 lines
1 <?php
2 // tests/integration/abilities/Test_Install_Ppg_Ability.php
3
4 namespace cybot\cookiebot\tests\integration\abilities;
5
6 use cybot\cookiebot\abilities\Ability_Audit_Logger;
7 use cybot\cookiebot\abilities\Install_Ppg_Ability;
8 use WP_UnitTestCase;
9
10 class Test_Install_Ppg_Ability extends WP_UnitTestCase {
11
12 /**
13 * @var Ability_Audit_Logger
14 */
15 private $logger;
16
17 public function set_up() {
18 parent::set_up();
19 $this->logger = new Ability_Audit_Logger();
20 delete_option( 'cookiebot-ai-action-log' );
21 }
22
23 public function tear_down() {
24 remove_all_filters( 'pre_option_active_plugins' );
25 remove_all_filters( 'plugins_api' );
26 remove_all_filters( 'all_plugins' );
27 parent::tear_down();
28 }
29
30 public function test_get_name() {
31 $this->assertSame( 'cookiebot/install-ppg', ( new Install_Ppg_Ability( $this->logger ) )->get_name() );
32 }
33
34 public function test_returns_was_already_active_when_plugin_active() {
35 add_filter( 'pre_option_active_plugins', function() {
36 return array( 'privacy-policy-usercentrics/privacy-policy-usercentrics.php' );
37 } );
38 $args = ( new Install_Ppg_Ability( $this->logger ) )->get_args();
39 $result = call_user_func( $args['execute_callback'] );
40 $this->assertTrue( $result['was_already_active'] );
41 $this->assertTrue( $result['success'] );
42 $this->assertArrayHasKey( 'admin_url', $result );
43 }
44
45 public function test_writes_audit_log_when_already_active() {
46 add_filter( 'pre_option_active_plugins', function() {
47 return array( 'privacy-policy-usercentrics/privacy-policy-usercentrics.php' );
48 } );
49 $args = ( new Install_Ppg_Ability( $this->logger ) )->get_args();
50 call_user_func( $args['execute_callback'] );
51 $log = get_option( 'cookiebot-ai-action-log', array() );
52 $this->assertCount( 1, $log );
53 $this->assertSame( 'cookiebot/install-ppg', $log[0]['ability'] );
54 }
55
56 public function test_returns_wp_error_when_plugins_api_fails() {
57 // Force plugins cache to empty so get_plugins() skips the filesystem scan
58 // and returns [] without finding privacy-policy-usercentrics.
59 wp_cache_set( 'plugins', array( '' => array() ), 'plugins' );
60 // Ensure plugin is not active.
61 add_filter( 'pre_option_active_plugins', function() {
62 return array();
63 } );
64 add_filter( 'plugins_api', function() {
65 return new \WP_Error( 'api_error', 'Connection failed.' );
66 } );
67 $args = ( new Install_Ppg_Ability( $this->logger ) )->get_args();
68 $result = call_user_func( $args['execute_callback'] );
69 $this->assertInstanceOf( 'WP_Error', $result );
70 $this->assertSame( 'cookiebot_ppg_install_failed', $result->get_error_code() );
71 }
72
73 public function test_show_in_rest_true() {
74 $args = ( new Install_Ppg_Ability( $this->logger ) )->get_args();
75 $this->assertTrue( $args['meta']['show_in_rest'] );
76 }
77 }
78