Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Piwik\Plugins\API\tests\System\AutoSuggestAPITest;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Plugins\CustomVariables\tests\Fixtures\TwoVisitsWithCustomVariables;
use Piwik\Version;

/**
* testing a segment containing all supported fields
Expand Down Expand Up @@ -41,6 +42,11 @@ public function getApiForTesting()
// we will test all segments from all plugins
$apiToCall = array('VisitsSummary.get', 'CustomVariables.getCustomVariables');

if (version_compare(Version::VERSION, '5.4.0-b3', '<')) {
// archive numbers changed, so we ignore VisitsSummary
$apiToCall = ['CustomVariables.getCustomVariables'];
}

return array(
array($apiToCall, array('idSite' => 'all',
'date' => self::$fixture->dateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Piwik\Db;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Plugins\CustomVariables\tests\Fixtures\TwoVisitsWithCustomVariables;
use Piwik\Version;

/**
* Tests use of custom variable segments.
Expand Down Expand Up @@ -77,6 +78,10 @@ public function getApiForTesting()
*/
public function testCheck()
{
if (version_compare(Version::VERSION, '5.4.0-b3', '<')) {
self::markTestSkipped('archive numbers have changed');
}

// TODO: if we do this in archivewriter, we don't need this code
$archivePurger = StaticContainer::get(ArchivePurger::class);
$archivePurger->purgeInvalidatedArchivesFrom(Date::factory(self::$fixture->dateTime));
Expand All @@ -96,37 +101,27 @@ public function testCheck()
// )
'archive_blob_2010_01' => 20,
// This contains all 'last N' weeks & days,
// (6 metrics
// + 2 referrer metrics
// (8 metrics
// + 6 referrer metrics
// + 3 done flag )
// * 2 segments
// for each "Last N" date that has data (just one date)
'archive_numeric_2010_01' => 22,
'archive_numeric_2010_01' => 34,

// 2) CHECK 'week' archive stored in December (week starts the month before)
// We expect 2 segments * (2 custom variable name + 2 ref metrics + 1 subtable chunk for the values of the name + 6 referrers blob (2 of them subtables))
'archive_blob_2009_12' => 20,
// 6 metrics,
// 2 Referrer metrics (Referrers_distinctSearchEngines/Referrers_distinctKeywords),
// 8 metrics,
// 6 Referrer metrics,
// 3 done flag (referrers, CustomVar, VisitsSummary), all for period = 2, day w/ visits is in new year, other days have no data
// X * 2 segments
'archive_numeric_2009_12' => (6 + 2 + 3) * 2,
'archive_numeric_2009_12' => (8 + 6 + 3) * 2,
);

foreach ($tests as $table => $expectedRows) {
$sql = "SELECT count(*) FROM " . Common::prefixTable($table);
$countBlobs = Db::get()->fetchOne($sql);

if ($expectedRows != $countBlobs) {
$output = Db::get()->fetchAll("SELECT * FROM " . Common::prefixTable($table) . " ORDER BY name, idarchive ASC");
if (strpos($table, 'blob') !== false) {
$output = array_map(function ($r) {
unset($r['value']);
return $r;
}, $output);
}
var_export('This is debug output from ' . __CLASS__ . ' in case of an error: ');
var_export($output);
}
$this->assertEquals($expectedRows, $countBlobs, "$table: %s");
}
}
Expand All @@ -138,6 +133,10 @@ public function testCheck()
*/
public function test_checkArchiveRecords_shouldMergeSubtablesIntoOneRow()
{
if (version_compare(Version::VERSION, '5.4.0-b3', '<')) {
self::markTestSkipped('archive numbers have changed');
}

$chunk = new Chunk();

$tests = array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result idSite="1">
<result date="2010-01-03" />
<result date="2010-01-03">
<nb_uniq_visitors>0</nb_uniq_visitors>
<nb_users>0</nb_users>
<nb_visits>0</nb_visits>
<nb_actions>0</nb_actions>
<nb_visits_converted>0</nb_visits_converted>
<bounce_count>0</bounce_count>
<sum_visit_length>0</sum_visit_length>
<max_actions>0</max_actions>
<bounce_rate>0%</bounce_rate>
<nb_actions_per_visit>0</nb_actions_per_visit>
<avg_time_on_site>0</avg_time_on_site>
</result>
<result date="2010-01-04" />
<result date="2010-01-05" />
<result date="2010-01-06" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result idSite="1">
<result date="2009-12-28,2010-01-03" />
<result date="2009-12-28,2010-01-03">
<nb_uniq_visitors>0</nb_uniq_visitors>
<nb_users>0</nb_users>
<nb_visits>0</nb_visits>
<nb_actions>0</nb_actions>
<nb_visits_converted>0</nb_visits_converted>
<bounce_count>0</bounce_count>
<sum_visit_length>0</sum_visit_length>
<max_actions>0</max_actions>
<bounce_rate>0%</bounce_rate>
<nb_actions_per_visit>0</nb_actions_per_visit>
<avg_time_on_site>0</avg_time_on_site>
</result>
<result date="2010-01-04,2010-01-10" />
<result date="2010-01-11,2010-01-17" />
<result date="2010-01-18,2010-01-24" />
Expand Down