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

PeriodTest.php « Core « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74953436f472c8b75fb7a9b2b410aafea14b26ce (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
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
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
use Piwik\Date;
use Piwik\Period\Day;
use Piwik\Period;
use Piwik\Period\Month;
use Piwik\Period\Week;
use Piwik\Period\Year;

class PeriodTest extends PHPUnit_Framework_TestCase
{
    /**
     * @group Core
     */
    public function testGetId()
    {
        $period = new Day(Date::today());
        $this->assertNotEquals(0, $period->getId());
        $period = new Week(Date::today());
        $this->assertNotEquals(0, $period->getId());
        $period = new Month(Date::today());
        $this->assertNotEquals(0, $period->getId());
        $period = new Year(Date::today());
        $this->assertNotEquals(0, $period->getId());
    }

    /**
     * @group Core
     */
    public function testGetLabel()
    {
        $period = new Day(Date::today());
        $label = $period->getLabel();
        $this->assertInternalType('string', $label);
        $this->assertNotEmpty($label);
        $period = new Week(Date::today());
        $label = $period->getLabel();
        $this->assertInternalType('string', $label);
        $this->assertNotEmpty($label);
        $period = new Month(Date::today());
        $label = $period->getLabel();
        $this->assertInternalType('string', $label);
        $this->assertNotEmpty($label);
        $period = new Year(Date::today());
        $label = $period->getLabel();
        $this->assertInternalType('string', $label);
        $this->assertNotEmpty($label);
    }

    /**
     * @group Core
     */
    public function testFactoryDay()
    {
        $period = Period\Factory::build('day', Date::today());
        $this->assertInstanceOf('\Piwik\Period\Day', $period);
    }

    /**
     * @group Core
     */
    public function testFactoryMonth()
    {
        $period = Period\Factory::build('month', Date::today());
        $this->assertInstanceOf('\Piwik\Period\Month', $period);
    }

    /**
     * @group Core
     */
    public function testFactoryWeek()
    {
        $period = Period\Factory::build('week', Date::today());
        $this->assertInstanceOf('\Piwik\Period\Week', $period);
    }

    /**
     * @group Core
     */
    public function testFactoryYear()
    {
        $period = Period\Factory::build('year', Date::today());
        $this->assertInstanceOf('\Piwik\Period\Year', $period);
    }

    /**
     * @group Core
     */
    public function testFactoryInvalid()
    {
        try {
            $period = Period\Factory::build('inValid', Date::today());
        } catch (Exception $e) {
            return;
        }
        $this->fail('Expected Exception not raised');
    }
}