Skip to content

Commit f37405e

Browse files
committed
fix more unit tests
1 parent 7272b5c commit f37405e

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

classes/WpMatomo/AIBotTracking.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ public function should_track_current_page() {
142142
return false;
143143
}
144144

145-
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
145+
if (
146+
! array_key_exists( 'REQUEST_URI', $_SERVER )
147+
|| null === $_SERVER['REQUEST_URI']
148+
) {
146149
return false;
147150
}
148151

tests/phpunit/wpmatomo/test-ai-bot-tracking.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function test_should_track_current_page_returns_false_for_admin_pages() {
8787
public function test_should_track_current_page_returns_false_if_no_request_uri_is_set() {
8888
$this->enable_ai_bot_tracking();
8989

90-
$this->unset_current_url();
90+
unset( $_SERVER['REQUEST_URI'] );
9191

9292
$should_track = $this->ai_bot_tracking->should_track_current_page();
9393
$this->assertFalse( $should_track );

tests/phpunit/wpmatomo/test-annotations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function test_add_annotation_when_post_type_allowed() {
8383
'id' => 1,
8484
'idsite' => 1,
8585
'date' => gmdate( 'Y-m-d' ),
86-
'note' => 'Published: hello-world - URL: https://example.org/?p=' . $post->ID,
86+
'note' => 'Published: hello-world - URL: http://example.org/?p=' . $post->ID,
8787
'starred' => 0,
8888
'user' => 'super user was set',
8989
'canEditOrDelete' => true,

tests/phpunit/wpmatomo/test-install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function test_install_adds_sites_and_users() {
8484
array(
8585
'idsite' => 1,
8686
'name' => 'Test Blog',
87-
'main_url' => 'https://example.org',
87+
'main_url' => 'http://example.org',
8888
'ecommerce' => 1,
8989
'sitesearch' => 1,
9090
'sitesearch_keyword_parameters' => '',

tests/phpunit/wpmatomo/test-paths.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ public function test_get_matomo_js_upload_path() {
7575
}
7676

7777
public function test_get_tracker_api_rest_api_endpoint() {
78-
$this->assertSame( 'https://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/matomo/v1/hit/', $this->paths->get_tracker_api_rest_api_endpoint() );
78+
$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/matomo/v1/hit/', $this->paths->get_tracker_api_rest_api_endpoint() );
7979
}
8080

8181
public function test_get_js_tracker_rest_api_endpoint() {
82-
$this->assertSame( 'https://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/matomo/v1/hit/', $this->paths->get_js_tracker_rest_api_endpoint() );
82+
$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/matomo/v1/hit/', $this->paths->get_js_tracker_rest_api_endpoint() );
8383
}
8484

8585
public function test_get_tracker_api_url_in_matomo_dir() {
86-
$this->assertSame( 'https://' . WP_TESTS_DOMAIN . '/wp-content/plugins/matomo/app/matomo.php', $this->paths->get_tracker_api_url_in_matomo_dir() );
86+
$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/wp-content/plugins/matomo/app/matomo.php', $this->paths->get_tracker_api_url_in_matomo_dir() );
8787
}
8888

8989
public function test_get_js_tracker_url_in_matomo_dir() {
90-
$this->assertSame( 'https://' . WP_TESTS_DOMAIN . '/wp-content/plugins/matomo/app/matomo.js', $this->paths->get_js_tracker_url_in_matomo_dir() );
90+
$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/wp-content/plugins/matomo/app/matomo.js', $this->paths->get_js_tracker_url_in_matomo_dir() );
9191
}
9292

9393
public function test_get_config_ini_path() {

tests/phpunit/wpmatomo/test-privacybadge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setUp(): void {
1515
}
1616

1717
public function test_privacy_badge_shortcode_no_options() {
18-
$this->assertSame( '<img alt="Your privacy protected! This website uses Matomo." src="https://example.org/wp-content/plugins/matomo/assets/img/privacybadge.png" width="120" height="120">', do_shortcode( '[matomo_privacy_badge]' ) );
18+
$this->assertSame( '<img alt="Your privacy protected! This website uses Matomo." src="http://example.org/wp-content/plugins/matomo/assets/img/privacybadge.png" width="120" height="120">', do_shortcode( '[matomo_privacy_badge]' ) );
1919
}
2020

2121
public function test_privacy_badge_shortcode_size() {

tests/phpunit/wpmatomo/test-trackingcode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function test_add_feed_tracking() {
210210

211211
$url = apply_filters( 'the_excerpt_rss', '<p>foobarbaz</p>' );
212212

213-
$this->assertStringStartsWith( '<p>foobarbaz</p><img src="//example.org/index.php?rest_route=/matomo/v1/hit/?idsite=23&amp;rec=1&amp;url=https%3A%2F%2Fexample.org%2F%3Fp%3D' . $post->ID . '&amp;action_name=hello-world&amp;urlref=https%3A%2F%2Fexample.org', $url );
213+
$this->assertStringStartsWith( '<p>foobarbaz</p><img src="//example.org/index.php?rest_route=/matomo/v1/hit/?idsite=23&amp;rec=1&amp;url=http%3A%2F%2Fexample.org%2F%3Fp%3D' . $post->ID . '&amp;action_name=hello-world&amp;urlref=http%3A%2F%2Fexample.org', $url );
214214
$this->assertStringEndsWith( '" style="border:0;width:0;height:0" width="0" height="0" alt="" />', $url );
215215
}
216216

0 commit comments

Comments
 (0)