Skip to content

Commit

Permalink
adjust some tests to work with MariaDb
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed May 7, 2024
1 parent fca078a commit 42eb5f1
Show file tree
Hide file tree
Showing 9 changed files with 995 additions and 980 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<nb_visits>35</nb_visits>
<nb_actions>95</nb_actions>
<nb_visits_converted>35</nb_visits_converted>
<bounce_count>18</bounce_count>
<sum_visit_length>27579</sum_visit_length>
<max_actions>5</max_actions>
<bounce_rate>51%</bounce_rate>
<nb_actions_per_visit>2.7</nb_actions_per_visit>
<avg_time_on_site>788</avg_time_on_site>
<nb_visits>1</nb_visits>
<nb_actions>1</nb_actions>
<nb_visits_converted>1</nb_visits_converted>
<bounce_count>1</bounce_count>
<sum_visit_length>0</sum_visit_length>
<max_actions>1</max_actions>
<bounce_rate>100%</bounce_rate>
<nb_actions_per_visit>1</nb_actions_per_visit>
<avg_time_on_site>0</avg_time_on_site>
</result>
13 changes: 9 additions & 4 deletions plugins/UsersManager/tests/Integration/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ public function testGetSitesAccessFromUserMultipleSites()
$this->model->addUserAccess($this->login, Write::ID, array(3));
$this->model->addUserAccess($this->login, Write::ID, array(2));
$this->model->addUserAccess($this->login, View::ID, array(1));
$access = $this->model->getSitesAccessFromUser($this->login);
// The order might differ depending on the database, so sort by 'idaction'
usort($access, function ($a, $b) {
return $a['site'] - $b['site'];
});
$this->assertEquals(array(
array('site' => '3', 'access' => Write::ID),
array('site' => '2', 'access' => Write::ID),
array('site' => '1', 'access' => View::ID),
), $this->model->getSitesAccessFromUser($this->login));
array('site' => '1', 'access' => View::ID),
array('site' => '2', 'access' => Write::ID),
array('site' => '3', 'access' => Write::ID),
), $access);
}

public function testGetSitesAccessFromUserMultipleSitesSomeNoLongerExist()
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function trackVisit(\MatomoTracker $t, $fixtureCounter, $visitorCounte
}

// first visit
$date = Date::factory($this->dateTime)->addDay($visitorCounter);
$date = Date::factory($this->dateTime)->addDay($visitorCounter)->addPeriod($fixtureCounter, 'SECOND');
$t->setForceVisitDateTime($date->getDatetime());
$t->setUrl("http://piwik.net/grue/lair");
$t->setCustomVariable(1, 'Cvar 1 name', 'Cvar1 value is ' . $visitorCounter, 'visit');
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPUnit/Framework/TestCase/SystemTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public static function isMysqli()
return getenv('MYSQL_ADAPTER') == 'MYSQLI';
}

public static function isMariaDb()
{
return getenv('MYSQL_SCHEMA') === 'Mariadb' || Config::getInstance()->database['schema'] === 'Mariadb';
}

/**
* Return 4 Api Urls for testing scheduled reports :
* - one in HTML format with all available reports
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function testGenerateQueryWithSegmentVisitLogJoinRightJoinOnOtherTableSho

public function testSetMaxExecutionTimeOfArchivingQueries()
{
if (SystemTestCase::isMysqli()) {
if (!SystemTestCase::isMariaDb() && SystemTestCase::isMysqli()) {
// See https://github.com/matomo-org/matomo/issues/17871
$this->markTestSkipped('Max execution query hint does not work for Mysqli.');
}
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPUnit/Integration/Tracker/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public function testGetIdsActionCorrectlyReturnsRequestedActionIds()
array('name' => 'action2', 'type' => 2)
));

// The order might differ depending on the database, so sort by 'idaction'
usort($result, function ($a, $b) {
return $a['idaction'] - $b['idaction'];
});

$expectedResult = array(
array(
'idaction' => '2',
Expand Down
Loading

0 comments on commit 42eb5f1

Please sign in to comment.