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
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Tests\Integration\ArchiveProcessor;
use Piwik\ArchiveProcessor\Parameters;
use Piwik\Segment;
use Piwik\Site;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\Period;
class ParametersTest extends IntegrationTestCase
{
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2012-02-01 00:00:00');
}
/**
* @dataProvider getTestDataForIsDayArchive
*/
public function test_isDayArchive_CorrectlyDetectsDayArchives($expected, $dateStr, $periodStr)
{
$period = Period\Factory::build($periodStr, $dateStr);
$params = new Parameters(new Site(1), $period, new Segment('', [1]));
$actual = $params->isDayArchive();
$this->assertEquals($expected, $actual);
}
public function getTestDataForIsDayArchive()
{
return [
[true, '2012-02-02', 'day'],
[false, '2013-03-04', 'week'],
[false, '2013-03-04', 'month'],
[false, '2013-03-04', 'year'],
[true, '2012-02-02,2012-02-02', 'range'],
[false, '2012-02-02,2012-02-03', 'range'],
[false, '2012-02-02,2012-02-05', 'range'],
];
}
}
|