Skip to content

Commit 5ae0173

Browse files
committed
Fixed test.
1 parent 9564a78 commit 5ae0173

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

tests/integration/InitOptionsTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,25 @@
1010

1111
class InitOptionsTest extends TestCase {
1212
/**
13-
* @return void
1413
* @see InitOptions::maybe_add_pageview_props()
14+
* @return void
1515
*/
1616
public function testAddPageviewProps() {
1717
try {
18-
global $post;
18+
global $post, $wp_query;
1919

20-
$post_id = wp_insert_post(
20+
$post_id = wp_insert_post(
2121
[
2222
'id' => 1,
2323
'post_author' => 1,
2424
'post_title' => 'Test',
2525
'post_content' => 'Test',
2626
]
2727
);
28-
$test_post = get_post( $post_id );
29-
$post = $test_post;
28+
$test_post = get_post( $post_id );
29+
$post = $test_post;
30+
$wp_query = new \WP_Query();
31+
$wp_query->is_single = true;
3032

3133
add_filter( 'plausible_analytics_settings', [ $this, 'enablePageviewProps' ] );
3234

@@ -46,9 +48,9 @@ public function testAddPageviewProps() {
4648
}
4749

4850
/**
51+
* @see InitOptions::maybe_add_proxy_options()
4952
* @return void
5053
* @throws \Exception
51-
* @see InitOptions::maybe_add_proxy_options()
5254
*/
5355
public function testAddProxyOptions() {
5456
try {
@@ -65,8 +67,8 @@ public function testAddProxyOptions() {
6567
}
6668

6769
/**
68-
* @return void
6970
* @see InitOptions::maybe_exclude_pageview()
71+
* @return void
7072
*/
7173
public function testExcludePageview() {
7274
/**
@@ -76,7 +78,7 @@ public function testExcludePageview() {
7678
add_filter( 'plausible_analytics_settings', [ $this, 'setExcludePageview' ] );
7779

7880
$class = $this->getMockBuilder( InitOptions::class )->disableOriginalConstructor()->onlyMethods( [
79-
'get_current_request'
81+
'get_current_request',
8082
] )->getMock();
8183

8284
$class->method( 'get_current_request' )->willReturn( 'http://example.com/category/test' );
@@ -86,7 +88,7 @@ public function testExcludePageview() {
8688
$this->assertArrayNotHasKey( 'transformRequest', $options );
8789

8890
$class = $this->getMockBuilder( InitOptions::class )->disableOriginalConstructor()->onlyMethods( [
89-
'get_current_request'
91+
'get_current_request',
9092
] )->getMock();
9193

9294
$class->method( 'get_current_request' )->willReturn( 'http://test.example.com/test' );
@@ -105,7 +107,7 @@ public function testExcludePageview() {
105107
add_filter( 'plausible_analytics_settings', [ $this, 'setExcludePageviewEdgeCaseAsterisk' ] );
106108

107109
$class = $this->getMockBuilder( InitOptions::class )->disableOriginalConstructor()->onlyMethods( [
108-
'get_current_request'
110+
'get_current_request',
109111
] )->getMock();
110112

111113
$class->method( 'get_current_request' )->willReturn( 'http://example.com/test' );
@@ -124,7 +126,7 @@ public function testExcludePageview() {
124126
add_filter( 'plausible_analytics_settings', [ $this, 'setExcludePageviewEdgeCaseSpace' ] );
125127

126128
$class = $this->getMockBuilder( InitOptions::class )->disableOriginalConstructor()->onlyMethods( [
127-
'get_current_request'
129+
'get_current_request',
128130
] )->getMock();
129131

130132
$class->method( 'get_current_request' )->willReturn( 'http://example.com/test' );
@@ -138,8 +140,8 @@ public function testExcludePageview() {
138140
}
139141

140142
/**
141-
* @return void
142143
* @see InitOptions::maybe_track_logged_in_users()
144+
* @return void
143145
*/
144146
public function testTrackLoggedInUsers() {
145147
try {

0 commit comments

Comments
 (0)