Skip to content

Commit 5c0855c

Browse files
committed
Added testTrackLoggedInUsers.
1 parent 46f2f2e commit 5c0855c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/integration/FiltersTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,32 @@ public function testAddPlausibleAttributes() {
2929

3030
$this->assertStringNotContainsString( 'plausible-analytics-js', $tag );
3131
}
32+
33+
/**
34+
* @see Filters::maybe_track_logged_in_users()
35+
*
36+
* @return void
37+
*/
38+
public function testTrackLoggedInUsers() {
39+
$class = new Filters();
40+
41+
add_filter( 'plausible_analytics_settings', [ $this, 'enablePageviewProps' ] );
42+
43+
$params = $class->maybe_track_logged_in_users( '' );
44+
45+
$this->assertStringContainsString( 'no', $params );
46+
47+
global $current_user;
48+
49+
$user = new \WP_User();
50+
$user->ID = 1;
51+
$user->roles = [ 'test' ];
52+
$current_user = $user;
53+
54+
$params = $class->maybe_track_logged_in_users( '' );
55+
56+
remove_filter( 'plausible_analytics_settings', [ $this, 'enablePageviewProps' ] );
57+
58+
$this->assertStringContainsString( 'test', $params );
59+
}
3260
}

0 commit comments

Comments
 (0)