blob: 7b28bf339eed6bff4cdb85bd70177474b9218f12 (
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
104
105
106
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\CorePluginsAdmin\tests\Integration;
use Piwik\Plugin;
use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group CorePluginsAdmin
* @group ApiTest
* @group Api
* @group Plugins
*/
class TagManagerTeaserTest extends IntegrationTestCase
{
/**
* @var TagManagerTeaser
*/
private $teaser;
public function setUp()
{
parent::setUp();
Plugin\Manager::getInstance()->deactivatePlugin('TagManager');
$this->teaser = $this->makeTeaser('mylogin');
}
private function makeTeaser($login)
{
return new TagManagerTeaser($login);
}
public function test_isEnabledGloballyByDefault()
{
$this->assertTrue($this->teaser->isEnabledGlobally());
}
public function test_disableGlobally()
{
$this->teaser->disableGlobally();
$this->assertFalse($this->teaser->isEnabledGlobally());
}
public function test_reset()
{
$this->teaser->disableGlobally();
$this->assertFalse($this->teaser->isEnabledGlobally());
$this->teaser->reset();
$this->assertTrue($this->teaser->isEnabledGlobally());
}
public function test_disableGlobally_removesUserSettings()
{
$this->teaser->disableForUser();
$this->assertFalse($this->teaser->isEnabledForUser());
$this->teaser->disableGlobally();
$this->assertFalse($this->teaser->isEnabledGlobally());
// should reset user enable flags cause disabled globally anyway
$this->assertTrue($this->teaser->isEnabledForUser());
}
public function test_isEnabledForCurrentUserByDefault()
{
$this->assertTrue($this->teaser->isEnabledForUser());
}
public function test_disableForUser()
{
$this->teaser->disableForUser();
$this->assertFalse($this->teaser->isEnabledForUser());
// still enabled globally
$this->assertTrue($this->teaser->isEnabledGlobally());
// still enabled for other user
$otherUser = $this->makeTeaser('foobar123');
$this->assertTrue($otherUser->isEnabledForUser());
}
public function test_shouldShowTeaser()
{
$this->assertTrue($this->teaser->shouldShowTeaser());
$this->assertTrue($this->teaser->isEnabledGlobally());
}
public function test_shouldShowTeaser_shouldNotBeShownWhenTagManagerEnabled()
{
Plugin\Manager::getInstance()->activatePlugin('TagManager');
$this->assertFalse($this->teaser->shouldShowTeaser());
// should have been disabled automatically
$this->assertFalse($this->teaser->isEnabledGlobally());
}
}
|