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_Ability_Audit_Logger.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_Ability_Audit_Logger.php
55 lines
1 <?php
2 // tests/integration/abilities/Test_Ability_Audit_Logger.php
3
4 namespace cybot\cookiebot\tests\integration\abilities;
5
6 use cybot\cookiebot\abilities\Ability_Audit_Logger;
7 use WP_UnitTestCase;
8
9 class Test_Ability_Audit_Logger extends WP_UnitTestCase {
10
11 public function set_up() {
12 parent::set_up();
13 delete_option( 'cookiebot-ai-action-log' );
14 }
15
16 public function test_log_creates_entry_with_correct_structure() {
17 $logger = new Ability_Audit_Logger();
18 $logger->log( 'cookiebot/set-cbid', 'old', 'new' );
19 $log = get_option( 'cookiebot-ai-action-log', array() );
20 $this->assertCount( 1, $log );
21 $this->assertSame( 'cookiebot/set-cbid', $log[0]['ability'] );
22 $this->assertSame( 'old', $log[0]['old'] );
23 $this->assertSame( 'new', $log[0]['new'] );
24 $this->assertArrayHasKey( 'ts', $log[0] );
25 $this->assertArrayHasKey( 'user_id', $log[0] );
26 }
27
28 public function test_log_prepends_newest_first() {
29 $logger = new Ability_Audit_Logger();
30 $logger->log( 'cookiebot/set-cbid', 'a', 'b' );
31 $logger->log( 'cookiebot/toggle-gcm', 'c', 'd' );
32 $log = get_option( 'cookiebot-ai-action-log', array() );
33 $this->assertSame( 'cookiebot/toggle-gcm', $log[0]['ability'] );
34 $this->assertSame( 'cookiebot/set-cbid', $log[1]['ability'] );
35 }
36
37 public function test_log_caps_at_50_entries() {
38 $logger = new Ability_Audit_Logger();
39 for ( $i = 0; $i < 55; $i++ ) {
40 $logger->log( 'cookiebot/set-cbid', 'old', 'new' );
41 }
42 $log = get_option( 'cookiebot-ai-action-log', array() );
43 $this->assertCount( 50, $log );
44 }
45
46 public function test_log_recovers_from_corrupted_option() {
47 update_option( 'cookiebot-ai-action-log', 'not-an-array' );
48 $logger = new Ability_Audit_Logger();
49 $logger->log( 'cookiebot/set-cbid', 'old', 'new' );
50 $log = get_option( 'cookiebot-ai-action-log', array() );
51 $this->assertCount( 1, $log );
52 $this->assertSame( 'cookiebot/set-cbid', $log[0]['ability'] );
53 }
54 }
55