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

VisitsInDifferentTimezones.php « Fixtures « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f47962e6d732e468fb8aa8b4ecc9f44fbf7ec82d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
use Piwik\Date;

/**
 * Adds one site with a non UTC timezone and tracks a couple visits near the end of the day.
 */
class Test_Piwik_Fixture_VisitsInDifferentTimezones extends Fixture
{
    public $idSite = 1;
    public $dateTime = '2010-03-06';
    public $date;

    public function __construct()
    {
        $this->date = Date::factory($this->dateTime)->toString();
    }

    public function setUp()
    {
        $this->setUpWebsitesAndGoals();
        $this->trackVisits();
    }

    public function tearDown()
    {
        // empty
    }

    private function setUpWebsitesAndGoals()
    {
        // tests run in UTC, the Tracker in UTC
        if (!self::siteCreated($idSite = 1)) {
            self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = false, $siteUrl = false,
                                $siteSearch = 1, $searchKeywordParameters = null,
                                $searchCategoryParameters = null, $timezone = 'America/New_York');
        }
    }

    private function trackVisits()
    {
        $dateTime = Date::factory($this->date)->addHour(27); // tracking a visit that is tomorrow in New York time
        $idSite = $this->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!'));
    }
}