blob: f6eecdab20227ffbcf1d2874b9b9ffc553d85476 (
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
|
<?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\CustomPiwikJs\tests\Integration;
use Piwik\Piwik;
use Piwik\Plugins\CustomPiwikJs\TrackingCode\PluginTrackerFiles;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
class CustomPluginTrackerFiles extends PluginTrackerFiles {
protected function getDirectoriesToLook() {
return array(
'CustomPiwikJs' => PIWIK_DOCUMENT_ROOT . '/plugins/CustomPiwikJs/tests/resources/'
);
}
}
/**
* @group CustomPiwikJs
* @group PluginTrackerFilesTest
* @group PluginTrackerFiles
* @group Plugins
*/
class PluginTrackerFilesTest extends IntegrationTestCase
{
public function test_find_ifAPluginDefinesAMinifiedAndARegularTrackerItShouldPreferTheMinifiedVersion()
{
$trackerFiles = new CustomPluginTrackerFiles();
$foundFiles = $trackerFiles->find();
$this->assertCount(1, $foundFiles);
$this->assertTrue(isset($foundFiles['CustomPiwikJs']));
$this->assertEquals('tracker.min.js', $foundFiles['CustomPiwikJs']->getName());
}
public function test_find_shouldIgnoreMinifiedVersion_IfRequested()
{
$trackerFiles = new CustomPluginTrackerFiles();
$trackerFiles->ignoreMinified();
$foundFiles = $trackerFiles->find();
$this->assertCount(1, $foundFiles);
$this->assertTrue(isset($foundFiles['CustomPiwikJs']));
$this->assertEquals('tracker.js', $foundFiles['CustomPiwikJs']->getName());
}
public function test_find_EventsCanIgnoreFiles()
{
$trackerFiles = new CustomPluginTrackerFiles();
$foundFiles = $trackerFiles->find();
$this->assertCount(1, $foundFiles);
Piwik::addAction('CustomPiwikJs.shouldAddTrackerFile', function (&$shouldAdd, $pluginName) {
if ($pluginName === 'CustomPiwikJs') {
$shouldAdd = false;
}
});
$foundFiles = $trackerFiles->find();
$this->assertCount(0, $foundFiles);
}
}
|