blob: 1e17f7253f277b1ae6a7d7f50f4c3dc4a157a4a6 (
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
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\PrivacyManager\tests;
use Piwik\Option;
use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group Plugins
*/
class PrivacyManagerConfigTest extends IntegrationTestCase
{
/**
* @var PrivacyManagerConfig
*/
private $config;
public function setUp()
{
parent::setUp();
$this->config = new PrivacyManagerConfig();
}
public function test_useAnonymizedIpForVisitEnrichment()
{
$this->assertTrue($this->config->useAnonymizedIpForVisitEnrichment);
$this->config->useAnonymizedIpForVisitEnrichment = false;
$this->assertFalse($this->config->useAnonymizedIpForVisitEnrichment);
$this->config->useAnonymizedIpForVisitEnrichment = true;
$this->assertTrue($this->config->useAnonymizedIpForVisitEnrichment);
}
public function test_doNotTrackEnabled()
{
$this->assertTrue($this->config->doNotTrackEnabled);
$this->config->doNotTrackEnabled = true;
$this->assertTrue($this->config->doNotTrackEnabled);
$this->config->doNotTrackEnabled = false;
$this->assertFalse($this->config->doNotTrackEnabled);
}
public function test_ipAnonymizerEnabled()
{
$this->assertTrue($this->config->ipAnonymizerEnabled);
$this->config->ipAnonymizerEnabled = false;
$this->assertFalse($this->config->ipAnonymizerEnabled);
}
public function test_ipAddressMaskLength()
{
$this->assertSame(2, $this->config->ipAddressMaskLength);
$this->config->ipAddressMaskLength = '19';
$this->assertSame(19, $this->config->ipAddressMaskLength);
}
public function test_setTrackerCacheContent()
{
$content = $this->config->setTrackerCacheGeneral(array('existingEntry' => 'test'));
$expected = array(
'existingEntry' => 'test',
'PrivacyManager.ipAddressMaskLength' => 2,
'PrivacyManager.ipAnonymizerEnabled' => true,
'PrivacyManager.doNotTrackEnabled' => true,
'PrivacyManager.useAnonymizedIpForVisitEnrichment' => true,
);
$this->assertEquals($expected, $content);
}
public function test_setTrackerCacheContent_ShouldGetValuesFromConfig()
{
Option::set('PrivacyManager.ipAddressMaskLength', '232');
$content = $this->config->setTrackerCacheGeneral(array('existingEntry' => 'test'));
$this->assertEquals(232, $content['PrivacyManager.ipAddressMaskLength']);
}
}
|