File: VisitsWithPagePerformanceMetrics.php

package info (click to toggle)
matomo 5.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 95,068 kB
  • sloc: php: 289,425; xml: 127,249; javascript: 112,130; python: 202; sh: 178; makefile: 20; sql: 10
file content (128 lines) | stat: -rw-r--r-- 5,348 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

/**
 * Matomo - free/libre analytics platform
 *
 * @link    https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

namespace Piwik\Plugins\PagePerformance\tests\Fixtures;

use Piwik\Date;
use Piwik\Plugins\SegmentEditor\API as APISegmentEditor;
use Piwik\Tests\Framework\Fixture;

/**
 * Adds two sites and tracks several visits all in the past.
 */
class VisitsWithPagePerformanceMetrics extends Fixture
{
    public $dateTime = '2010-03-12 01:22:33';
    public $idSite = 1;

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

        APISegmentEditor::getInstance()->add(
            'my segment',
            'actions>=1',
            $idSite = 1,
            $autoArchive = false,
            $enabledAllUsers = true
        );
    }

    public function tearDown(): void
    {
        // empty
    }

    public function setUpWebsitesAndGoals()
    {
        if (!self::siteCreated($idSite = 1)) {
            self::createWebsite($this->dateTime);
        }
    }

    protected function trackVisits()
    {
        $t = self::getTracker($this->idSite, $this->dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(12, 150, 333, 1101, 369, 150);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(0, 99, 298, 999, 412, 232);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(36, 77, 412, 1055, 333, 77);
        self::checkResponse($t->doTrackPageView('Contact'));

        $dateTime = Date::factory($this->dateTime)->subDay(1)->addHour(2.6)->getDatetime();

        $t = self::getTracker($this->idSite, $dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(12, 222, 211, 888, 299, 99);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(6, 99, 298, 1300, 348, 199);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(36, 77, 412, 1140, 444, 120);
        self::checkResponse($t->doTrackPageView('Contact'));

        $dateTime = Date::factory($this->dateTime)->subDay(2)->addHour(6.5)->getDatetime();

        $t = self::getTracker($this->idSite, $dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(29, 355, 444, 1300, 512, 333);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(66, 111, 278, 988, 355, 66);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(23, 211, 399, 998, 355, 222);
        self::checkResponse($t->doTrackPageView('Contact'));

        $dateTime = Date::factory($this->dateTime)->subDay(3)->addHour(4.1)->getDatetime();

        $t = self::getTracker($this->idSite, $dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(66, 277, 388, 1025, 436, 299);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(98, 99, 199, 899, 236, 100);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(30, 123, 255, 1200, 233, 258);
        self::checkResponse($t->doTrackPageView('Contact'));

        $dateTime = Date::factory($this->dateTime)->subDay(4)->addHour(4.1)->getDatetime();

        $t = self::getTracker($this->idSite, $dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(13, 158, 136, 1235, 359, 248);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(35, 132, 205, 1125, 236, 135);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(40, 269, 195, 963, 195, 215);
        self::checkResponse($t->doTrackPageView('Contact'));

        $dateTime = Date::factory($this->dateTime)->subDay(15)->addHour(2.6)->getDatetime();

        $t = self::getTracker($this->idSite, $dateTime, $defaultInit = true);
        $t->setUrl('http://example.org/category/Page1');
        $t->setPerformanceTimings(19, 222, 211, 888, 299, 99);
        self::checkResponse($t->doTrackPageView('Page Title 1'));
        $t->setUrl('http://example.org/Contact');
        $t->setPerformanceTimings(22, 99, 298, 1300, 348, 199);
        self::checkResponse($t->doTrackPageView('Contact'));
        $t->setUrl('http://example.org/Contact/ThankYou');
        $t->setPerformanceTimings(69, 77, 412, 1140, 444, 120);
        self::checkResponse($t->doTrackPageView('Contact'));
    }
}