Skip to content

Commit 3218171

Browse files
committed
fix unit test failure caused by cached data in matomo environment
1 parent e83e1b4 commit 3218171

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
backupGlobals="false"
66
colors="true"
77
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
8-
testdox="true"
98
>
109
<testsuites>
1110
<testsuite name="integration">

plugins/.htaccess

100644100755
File mode changed.

tests/phpunit/wpmatomo/report/test-dates.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
use WpMatomo\Report\Dates;
7+
use WpMatomo\User;
78

89
class ReportDatesTest extends MatomoAnalytics_TestCase {
910

@@ -12,10 +13,13 @@ class ReportDatesTest extends MatomoAnalytics_TestCase {
1213
*/
1314
private $dates;
1415

16+
private $user_id;
17+
1518
public function setUp(): void {
1619
parent::setUp();
1720

18-
$this->dates = new Dates();
21+
$this->dates = new Dates();
22+
$this->user_id = $this->create_set_super_admin();
1923
}
2024

2125
public function test_get_supported_dates() {
@@ -54,7 +58,9 @@ public function get_report_dates() {
5458
public function test_get_date_from_query( $query, $default_date, $expected ) {
5559
$_REQUEST = $query;
5660

57-
wp_set_current_user( 1 );
61+
wp_set_current_user( $this->user_id );
62+
// reloadAccess will not execute if the current user has super user access
63+
\Piwik\Access::getInstance()->setSuperUserAccess( false );
5864
\Piwik\Access::getInstance()->reloadAccess( new \Piwik\Plugins\WordPress\SessionAuth() );
5965

6066
$login = \Piwik\Access::getInstance()->getLogin();

0 commit comments

Comments
 (0)