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 <diosmosis@users.noreply.github.com>2018-12-14 04:29:27 +0300
committerGitHub <noreply@github.com>2018-12-14 04:29:27 +0300
commitef323275e351ab26370ba67aa5ca62b85035cb45 (patch)
tree088b6ede4170ebf545cc90b8c729b0b448de4196 /tests/PHPUnit/Fixtures
parent24b26c6370b6792b6770a8eefcd59bcd9a92f81a (diff)
For special dates in evolution graphs, calculate date & timezone together, to get proper result. (#13799)
* Update TimezonesTest to be more useful. * Update TimezonesTest which will not pass until https://github.com/matomo-org/matomo/issues/13829 * Non-intrusively fix evolution graph timezone end date issue using new Date method. * Make sure Date::factoryInTimezone only works w/ special word times.
Diffstat (limited to 'tests/PHPUnit/Fixtures')
-rw-r--r--tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php39
1 files changed, 32 insertions, 7 deletions
diff --git a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
index d5c1070f2d..db9c23833c 100644
--- a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
+++ b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php
@@ -16,6 +16,7 @@ use Piwik\Tests\Framework\Fixture;
class VisitsInDifferentTimezones extends Fixture
{
public $idSite = 1;
+ public $idSite2 = 2;
public $dateTime = '2010-03-06';
public $date;
@@ -39,21 +40,45 @@ class VisitsInDifferentTimezones extends Fixture
{
// tests run in UTC, the Tracker in UTC
if (!self::siteCreated($idSite = 1)) {
- self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = false, $siteUrl = false,
+ self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'site in EST', $siteUrl = false,
$siteSearch = 1, $searchKeywordParameters = null,
$searchCategoryParameters = null, $timezone = 'America/New_York');
}
+ if (!self::siteCreated($idSite = 2)) {
+ self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'site in UTC', $siteUrl = false,
+ $siteSearch = 1, $searchKeywordParameters = null,
+ $searchCategoryParameters = null, $timezone = 'UTC');
+ }
}
private function trackVisits()
{
- $dateTime = Date::factory($this->date)->addHour(27); // tracking a visit that is tomorrow in New York time
- $idSite = $this->idSite;
+ // track 2 hours before today in UTC. for utc website, there will be 1 visit yesterday, 0 today.
+ // for est website, there will be 0 visit yesterday, 1 today.
+ $dateTime = Date::factory('today')->subHour(2)->getDatetime();
- $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
+ foreach ([$this->idSite, $this->idSite2] as $idSite) {
+ $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
- // visit that is 'tomorrow' in UTC
- $t->setUrl('http://example.org/index.htm');
- self::checkResponse($t->doTrackPageView('incredible title!'));
+ // visit that is 'tomorrow' in UTC
+ $t->setUrl('http://example.org/index.htm');
+ self::checkResponse($t->doTrackPageView('incredible title!'));
+ }
+ }
+
+ public function provideContainerConfig()
+ {
+ $this->setMockNow();
+
+ return parent::provideContainerConfig();
+ }
+
+ public function setMockNow()
+ {
+ // set now to 1:00 am today
+ $now = time();
+ $now = $now - ($now % 86400);
+ $now = $now + 3600;
+ Date::$now = $now;
}
} \ No newline at end of file