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

ThreeGoalsOnePageview.php « Fixtures « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f055f4de6e48f493e2dbda19788a62be1322e7d (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
57
58
59
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

/**
 * Fixture that adds one site with three goals and tracks one pageview & one manual
 * goal conversion.
 */
class Test_Piwik_Fixture_ThreeGoalsOnePageview extends Test_Piwik_BaseFixture
{
    public $dateTime = '2009-01-04 00:11:42';
    public $idSite = 1;
    public $idGoal = 1;
    public $idGoal2 = 2;
    public $idGoal3 = 3;

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

    public function tearDown()
    {
        // empty
    }

    private function setUpWebsitesAndGoals()
    {
        self::createWebsite($this->dateTime, $ecommerce = 1);
        Piwik_Goals_API::getInstance()->addGoal(
            $this->idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false,
            $revenue = 10, $allowMultipleConversions = 1
        );

        Piwik_Goals_API::getInstance()->addGoal(
            $this->idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false,
            $revenue = 10, $allowMultipleConversions = 0
        );

        Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
    }

    private function trackVisits()
    {
        $t = self::getTracker($this->idSite, $this->dateTime, $defaultInit = true);

        // Record 1st page view
        $t->setUrl('http://example.org/index.htm');
        self::checkResponse($t->doTrackPageView('0'));

        $t->setForceVisitDateTime(Piwik_Date::factory($this->dateTime)->addHour(0.3)->getDatetime());
        self::checkResponse($t->doTrackGoal($this->idGoal3, $revenue = 42.256));
    }
}