Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-05-15 11:21:54 +0300
committerdiosmosis <benaka@piwik.pro>2015-06-11 09:45:18 +0300
commit794f05644fa01ce359d768a4650557b484d2b233 (patch)
treea9cfe70d1a22909f6ba12c221b9f8f387aaf5e37 /plugins/PrivacyManager
parente01af7d1c39e2ba3bac756eb21d0e66664759c9b (diff)
Refs #7180, add test that checks logs are correctly purged even if visits are tracked in the past.
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r--plugins/PrivacyManager/tests/Integration/DataPurgingTest.php38
1 files changed, 32 insertions, 6 deletions
diff --git a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
index 9ab94f9384..1f79d34b82 100644
--- a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
+++ b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php
@@ -10,11 +10,11 @@ namespace Piwik\Plugins\PrivacyManager\tests\Integration;
use Piwik\Archive;
use Piwik\Common;
use Piwik\Config;
-use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\DataAccess\RawLogDao;
use Piwik\Date;
use Piwik\Db;
use Piwik\LogDeleter;
+use Piwik\DbHelper;
use Piwik\Option;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Plugins\Goals\Archiver;
@@ -239,6 +239,21 @@ class DataPurgingTest extends IntegrationTestCase
$this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->_getTableCount($archiveTables['blob'][1])); // February
}
+ public function test_LogDataPurging_WorksWhenVisitsInPastTracked()
+ {
+ DbHelper::deleteArchiveTables();
+
+ self::trackVisitInPast();
+ self::_addReportData();
+
+ $this->_setTimeToRun();
+ $this->assertTrue( $this->instance->deleteLogData() );
+
+ $this->checkLogDataPurged();
+
+ // NOTE: it is not expected that the data purging estimate will work when visits in the past are tracked
+ }
+
/**
* Make sure nothing happens when deleting logs & reports are both disabled.
*/
@@ -271,10 +286,8 @@ class DataPurgingTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteLogsNoData()
{
- \Piwik\DbHelper::truncateAllTables();
- foreach (ArchiveTableCreator::getTablesArchivesInstalled() as $table) {
- Db::exec("DROP TABLE $table");
- }
+ DbHelper::truncateAllTables();
+ DbHelper::deleteArchiveTables();
// get purge data prediction
$prediction = PrivacyManager::getPurgeEstimate();
@@ -669,6 +682,20 @@ class DataPurgingTest extends IntegrationTestCase
Fixture::checkBulkTrackingResponse($t->doBulkTrack());
}
+ protected static function trackVisitInPast()
+ {
+ $start = Date::factory(self::$dateTime);
+
+ // add a visit in the past so the idvisit will be greater than the others, but the time will be older
+ // this tests issue #7180
+ $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true);
+ // we subtract 5 so it will be on the same day as another visit. this way, we won't create another day archive
+ // and change the counts in asserts
+ $t->setForceVisitDateTime($start->subDay(self::$daysAgoStart - 5));
+ $t->setUrl("http://whatever.com/days_in_past");
+ $t->doTrackPageView('visit in past');
+ }
+
protected static function _addReportData()
{
$date = Date::factory(self::$dateTime);
@@ -768,7 +795,6 @@ class DataPurgingTest extends IntegrationTestCase
$this->assertEquals(45, $this->_getTableCount('log_action'));
$archiveTables = self::_getArchiveTableNames();
- //var_export(Db::fetchAll("SELECT * FROM " . Common::prefixTable($archiveTables['numeric'][0])));
$janMetricCount = $this->_getExpectedNumericArchiveCountJan();
$this->assertEquals($janMetricCount, $this->_getTableCount($archiveTables['numeric'][0])); // January