diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-12-22 05:32:06 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-12-22 05:32:06 +0300 |
commit | 55fe05468d86dc51ad653b5de9bb4b9ad027ba78 (patch) | |
tree | d6ae3b30d6bf651ef298f31d82337ac5fdf8a0f2 /tests/PHPUnit | |
parent | e71f461adfd03b40504243104944fe6b70c79980 (diff) |
fix tests as reports are invalidated now in some tests causing the site creation date to change causing archiving more dates
Diffstat (limited to 'tests/PHPUnit')
7 files changed, 163 insertions, 22 deletions
diff --git a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php index 5e508f9d0b..3ec434d552 100644 --- a/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php +++ b/tests/PHPUnit/Fixtures/TwoSitesVisitsInPast.php @@ -15,10 +15,10 @@ use Piwik\Tests\Framework\Fixture; */ class TwoSitesVisitsInPast extends Fixture { - public $dateTimeFirstDateWebsite1 = '2010-03-06 01:22:33'; - public $dateTimeDateInPastWebsite1 = '2010-01-06 01:22:33'; - public $dateTimeFirstDateWebsite2 = '2010-01-03 20:22:33'; - public $dateTimeDateInPastWebsite2 = '2009-10-30 01:22:33'; + public $dateTimeCreationWebsite1 = '2010-03-06 01:22:33'; + public $dateTimeInPastWebsite1 = '2010-01-06 01:22:33'; + public $dateTimeCreationWebsite2 = '2010-01-03 20:22:33'; + public $dateTimeInPastWebsite2 = '2009-10-30 01:22:33'; public $idSite = 1; public $idSite2 = 2; @@ -36,11 +36,11 @@ class TwoSitesVisitsInPast extends Fixture public function setUpWebsitesAndGoals() { if (!self::siteCreated($idSite = 1)) { - self::createWebsite($this->dateTimeFirstDateWebsite1); + self::createWebsite($this->dateTimeCreationWebsite1); } if (!self::siteCreated($idSite = 2)) { - self::createWebsite($this->dateTimeFirstDateWebsite2); + self::createWebsite($this->dateTimeCreationWebsite2); } } @@ -50,7 +50,7 @@ class TwoSitesVisitsInPast extends Fixture * Track Visits normal date for the 2 websites */ // WEBSITE 1 - $t = self::getTracker($this->idSite, $this->dateTimeFirstDateWebsite1, $defaultInit = true); + $t = self::getTracker($this->idSite, $this->dateTimeCreationWebsite1, $defaultInit = true); $t->setUrl('http://example.org/category/Page1'); self::checkResponse($t->doTrackPageView('Hello')); $t->setUrl('http://example.org/category/Page2'); @@ -65,7 +65,7 @@ class TwoSitesVisitsInPast extends Fixture self::checkResponse($t->doTrackPageView('Hello')); // WEBSITE 2 - $t = self::getTracker($this->idSite2, $this->dateTimeFirstDateWebsite2, $defaultInit = true); + $t = self::getTracker($this->idSite2, $this->dateTimeCreationWebsite2, $defaultInit = true); $t->setIp('156.15.13.12'); $t->setUrl('http://example.org/category/Page1'); self::checkResponse($t->doTrackPageView('Hello')); @@ -84,7 +84,7 @@ class TwoSitesVisitsInPast extends Fixture * Track visits in the past (before website creation date) for the 2 websites */ // WEBSITE1 - $t = self::getTracker($this->idSite, $this->dateTimeDateInPastWebsite1, $defaultInit = true); + $t = self::getTracker($this->idSite, $this->dateTimeInPastWebsite1, $defaultInit = true); $t->setIp('156.5.55.2'); $t->setUrl('http://example.org/category/Page1'); self::checkResponse($t->doTrackPageView('Hello')); @@ -96,7 +96,7 @@ class TwoSitesVisitsInPast extends Fixture self::checkResponse($t->doTrackPageView('Blabla')); // WEBSITE2 - $t = self::getTracker($this->idSite2, $this->dateTimeDateInPastWebsite2, $defaultInit = true); + $t = self::getTracker($this->idSite2, $this->dateTimeInPastWebsite2, $defaultInit = true); $t->setIp('156.52.3.22'); $t->setUrl('http://example.org/category/Page1'); self::checkResponse($t->doTrackPageView('Hello')); @@ -106,7 +106,7 @@ class TwoSitesVisitsInPast extends Fixture self::checkResponse($t->doTrackPageView('Hello')); $t->setUrl('http://example.org/category/Pageyy'); self::checkResponse($t->doTrackPageView('Blabla')); - $t->setForceVisitDateTime(Date::factory($this->dateTimeDateInPastWebsite2)->addHour(0.1)->getDatetime()); + $t->setForceVisitDateTime(Date::factory($this->dateTimeInPastWebsite2)->addHour(0.1)->getDatetime()); $t->setUrl('http://example.org/category/Pageyy'); self::checkResponse($t->doTrackPageView('Blabla')); } diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php index f8d3ab4f15..06ee848eed 100755 --- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php +++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest.php @@ -8,6 +8,8 @@ namespace Piwik\Tests\System; use Piwik\Common; +use Piwik\DataAccess\ArchiveInvalidator; +use Piwik\DataAccess\InvalidatedReports; use Piwik\Db; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables; @@ -88,9 +90,9 @@ class TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest extends SystemTest 'archive_blob_2009_12' => 28, // 7 metrics, // 2 Referrer metrics (Referrers_distinctSearchEngines/Referrers_distinctKeywords), - // 3 done flag (referrers, CustomVar, VisitsSummary), + // 6 done flag (referrers, CustomVar, VisitsSummary), 3 for period = 1 and 3 for period = 2 // X * 2 segments - 'archive_numeric_2009_12' => (6 + 2 + 3) * 2, + 'archive_numeric_2009_12' => (6 + 2 + 3 + 3) * 2, ); foreach ($tests as $table => $expectedRows) { $sql = "SELECT count(*) FROM " . Common::prefixTable($table); @@ -98,7 +100,8 @@ class TwoVisitsWithCustomVariablesSegmentMatchVisitorTypeTest extends SystemTest if($expectedRows != $countBlobs) { $output = Db::get()->fetchAll("SELECT * FROM " . Common::prefixTable($table) . " ORDER BY name, idarchive ASC"); - var_export('This is debug output from ' . __CLASS__ . ' in case of an error: ' . $output); + var_export('This is debug output from ' . __CLASS__ . ' in case of an error: '); + var_export($output); } $this->assertEquals($expectedRows, $countBlobs, "$table: %s"); } diff --git a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php index 859eda1646..b951995368 100644 --- a/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php +++ b/tests/PHPUnit/System/VisitsInPastInvalidateOldReportsTest.php @@ -42,8 +42,8 @@ class VisitsInPastInvalidateOldReportsTest extends SystemTestCase { $idSite = self::$fixture->idSite; $idSite2 = self::$fixture->idSite2; - $dateTimeDateInPastWebsite1 = self::$fixture->dateTimeDateInPastWebsite1; - $dateTimeDateInPastWebsite2 = self::$fixture->dateTimeDateInPastWebsite2; + $dateTimeDateInPastWebsite1 = self::$fixture->dateTimeInPastWebsite1; + $dateTimeDateInPastWebsite2 = self::$fixture->dateTimeInPastWebsite2; // We test a typical Numeric and a Recursive blob reports $apiToCall = array('VisitsSummary.get', 'Actions.getPageUrls'); @@ -124,8 +124,8 @@ class VisitsInPastInvalidateOldReportsTest extends SystemTestCase { $idSite = self::$fixture->idSite; $idSite2 = self::$fixture->idSite2; - $dateTimeDateInPastWebsite1 = self::$fixture->dateTimeDateInPastWebsite1; - $dateTimeDateInPastWebsite2 = self::$fixture->dateTimeDateInPastWebsite2; + $dateTimeDateInPastWebsite1 = self::$fixture->dateTimeInPastWebsite1; + $dateTimeDateInPastWebsite2 = self::$fixture->dateTimeInPastWebsite2; $apiToCall = array('VisitsSummary.get', 'Actions.getPageUrls'); diff --git a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml index 89eec3fbc3..2f10eb3f97 100644 --- a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml +++ b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml @@ -1,6 +1,63 @@ <?xml version="1.0" encoding="utf-8" ?> <results> - <result date="2010-01" /> + <result date="2010-01"> + <row> + <label>category</label> + <nb_visits>3</nb_visits> + <nb_hits>4</nb_hits> + <sum_time_spent>0</sum_time_spent> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>4</entry_nb_actions> + <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <exit_nb_visits>1</exit_nb_visits> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>33%</exit_rate> + <subtable> + <row> + <label>/Page1</label> + <nb_visits>1</nb_visits> + <nb_hits>2</nb_hits> + <sum_time_spent>0</sum_time_spent> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>4</entry_nb_actions> + <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page1</url> + </row> + <row> + <label>/Page2</label> + <nb_visits>1</nb_visits> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page2</url> + </row> + <row> + <label>/Pagexx</label> + <nb_visits>1</nb_visits> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <exit_nb_visits>1</exit_nb_visits> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <url>http://example.org/category/Pagexx</url> + </row> + </subtable> + </row> + </result> <result date="2010-02" /> <result date="2010-03"> <row> diff --git a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__VisitsSummary.get_month.xml b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__VisitsSummary.get_month.xml index d84e6c4f35..2f7ce19aa5 100644 --- a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__VisitsSummary.get_month.xml +++ b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite1_OldReportsShouldNotAppear__VisitsSummary.get_month.xml @@ -1,6 +1,18 @@ <?xml version="1.0" encoding="utf-8" ?> <results> - <result date="2010-01" /> + <result date="2010-01"> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_users>0</nb_users> + <nb_visits>1</nb_visits> + <nb_actions>4</nb_actions> + <nb_visits_converted>0</nb_visits_converted> + <bounce_count>0</bounce_count> + <sum_visit_length>1</sum_visit_length> + <max_actions>4</max_actions> + <bounce_rate>0%</bounce_rate> + <nb_actions_per_visit>4</nb_actions_per_visit> + <avg_time_on_site>1</avg_time_on_site> + </result> <result date="2010-02" /> <result date="2010-03"> <nb_uniq_visitors>1</nb_uniq_visitors> diff --git a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml index aaef3a0ec5..401e8d2dc7 100644 --- a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml +++ b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__Actions.getPageUrls_month.xml @@ -1,6 +1,63 @@ <?xml version="1.0" encoding="utf-8" ?> <results> - <result date="2009-10" /> + <result date="2009-10"> + <row> + <label>category</label> + <nb_visits>3</nb_visits> + <nb_hits>5</nb_hits> + <sum_time_spent>360</sum_time_spent> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>5</entry_nb_actions> + <entry_sum_visit_length>361</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <exit_nb_visits>1</exit_nb_visits> + <avg_time_on_page>120</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>33%</exit_rate> + <subtable> + <row> + <label>/Page1</label> + <nb_visits>1</nb_visits> + <nb_hits>2</nb_hits> + <sum_time_spent>0</sum_time_spent> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>5</entry_nb_actions> + <entry_sum_visit_length>361</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page1</url> + </row> + <row> + <label>/Page2</label> + <nb_visits>1</nb_visits> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page2</url> + </row> + <row> + <label>/Pageyy</label> + <nb_visits>1</nb_visits> + <nb_hits>2</nb_hits> + <sum_time_spent>360</sum_time_spent> + <exit_nb_visits>1</exit_nb_visits> + <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors> + <avg_time_on_page>360</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <url>http://example.org/category/Pageyy</url> + </row> + </subtable> + </row> + </result> <result date="2009-11" /> <result date="2009-12" /> <result date="2010-01"> diff --git a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__VisitsSummary.get_month.xml b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__VisitsSummary.get_month.xml index d046dca549..ed3e2b6ade 100644 --- a/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__VisitsSummary.get_month.xml +++ b/tests/PHPUnit/System/expected/test_VisitsInPast_InvalidateOldReportsWebsite2_OldReportsShouldNotAppear__VisitsSummary.get_month.xml @@ -1,6 +1,18 @@ <?xml version="1.0" encoding="utf-8" ?> <results> - <result date="2009-10" /> + <result date="2009-10"> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_users>0</nb_users> + <nb_visits>1</nb_visits> + <nb_actions>5</nb_actions> + <nb_visits_converted>0</nb_visits_converted> + <bounce_count>0</bounce_count> + <sum_visit_length>361</sum_visit_length> + <max_actions>5</max_actions> + <bounce_rate>0%</bounce_rate> + <nb_actions_per_visit>5</nb_actions_per_visit> + <avg_time_on_site>361</avg_time_on_site> + </result> <result date="2009-11" /> <result date="2009-12" /> <result date="2010-01"> |