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
|
<?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;
use Piwik\Period\Year;
use Piwik\Translate;
/**
* Testing Period_Year
*/
class Period_YearTest extends PHPUnit_Framework_TestCase
{
/**
* test normal case
* @group Core
*/
public function testYearNormalcase()
{
$correct = array(
'2024-01-01',
'2024-02-01',
'2024-03-01',
'2024-04-01',
'2024-05-01',
'2024-06-01',
'2024-07-01',
'2024-08-01',
'2024-09-01',
'2024-10-01',
'2024-11-01',
'2024-12-01',);
$year = new Year(Date::factory('2024-10-09'));
$this->assertEquals(12, $year->getNumberOfSubperiods());
$this->assertEquals($correct, $year->toString());
}
/**
* test past
* @group Core
*/
public function testYearPastAndWrongdate()
{
$correct = array(
'2000-01-01',
'2000-02-01',
'2000-03-01',
'2000-04-01',
'2000-05-01',
'2000-06-01',
'2000-07-01',
'2000-08-01',
'2000-09-01',
'2000-10-01',
'2000-11-01',
'2000-12-01',
);
$year = new Year(Date::factory('2000-02-15'));
$this->assertEquals(12, $year->getNumberOfSubperiods());
$this->assertEquals($correct, $year->toString());
}
/**
* @group Core
*/
public function testGetLocalizedShortString()
{
Translate::loadEnglishTranslation();
$year = new Year(Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getLocalizedShortString());
}
/**
* @group Core
*/
public function testGetLocalizedLongString()
{
Translate::loadEnglishTranslation();
$year = new Year(Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getLocalizedLongString());
}
/**
* @group Core
*/
public function testGetPrettyString()
{
Translate::loadEnglishTranslation();
$year = new Year(Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getPrettyString());
}
}
|