blob: ea852ce60ac2a5bc64b5630f707acc308482e8a5 (
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
|
<?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\Columns;
use Piwik\Columns\ComputedMetricFactory;
use Piwik\Columns\MetricsList;
use Piwik\Plugin\ComputedMetric;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group Core
*/
class ComputedMetricFactoryTest extends IntegrationTestCase
{
/**
* @var ComputedMetricFactory
*/
private $factory;
public function setUp(): void
{
parent::setUp();
Fixture::loadAllTranslations();
$this->factory = new ComputedMetricFactory(MetricsList::get());
}
public function tearDown(): void
{
Fixture::resetTranslations();
parent::tearDown();
}
public function test_createComputedMetric_createAvgMetric()
{
$metric = $this->factory->createComputedMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_AVG);
$this->assertSame('avg_bounce_count_per_visits', $metric->getName());
$this->assertSame('Avg. Actions In Visit per Visit', $metric->getTranslatedName());
$this->assertSame('Average value of "Actions In Visit" per "Visits".', $metric->getDocumentation());
$this->assertSame('General_Visitors', $metric->getCategoryId());
}
public function test_createComputedMetric_createRateMetric()
{
$metric = $this->factory->createComputedMetric('bounce_count', 'nb_visits', ComputedMetric::AGGREGATION_RATE);
$this->assertSame('bounce_count_visits_rate', $metric->getName());
$this->assertSame('Bounces Rate', $metric->getTranslatedName());
$this->assertSame('The ratio of "Actions In Visit" out of all "Visits".', $metric->getDocumentation());
$this->assertSame('General_Visitors', $metric->getCategoryId());
}
}
|