|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ElliotSawyer\Matomo; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
6
|
|
|
use SilverStripe\SiteConfig\SiteConfig; |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class MatomoTest extends SapphireTest |
|
9
|
|
|
{ |
|
10
|
|
|
protected static $fixture_file = 'fixtures/Matomo.yml'; |
|
11
|
|
|
|
|
12
|
|
|
public function testMatomoSiteConfigFields() |
|
13
|
|
|
{ |
|
14
|
|
|
//applied via SiteConfig |
|
15
|
|
|
$config1 = $this->objFromFixture(SiteConfig::class, 'good1'); |
|
16
|
|
|
//add trailing slash |
|
17
|
|
|
$config1->write(); |
|
18
|
|
|
$this->assertEquals('//matomotest-test-test.test/', $config1->MatomoTrackingURL); |
|
19
|
|
|
$this->assertEquals('1234', $config1->MatomoSiteId); |
|
20
|
|
|
|
|
21
|
|
|
//applied via SiteConfig |
|
22
|
|
|
$config2 = $this->objFromFixture(SiteConfig::class, 'good2'); |
|
23
|
|
|
//add trailing slash |
|
24
|
|
|
$config2->write(); |
|
25
|
|
|
$this->assertEquals('//matomotest-test-test.test/', $config2->MatomoTrackingURL); |
|
26
|
|
|
$this->assertEquals('1234', $config1->MatomoSiteId); |
|
27
|
|
|
|
|
28
|
|
|
//applied via SiteConfig |
|
29
|
|
|
$config3 = $this->objFromFixture(SiteConfig::class, 'good3'); |
|
30
|
|
|
//add trailing slash |
|
31
|
|
|
$config3->write(); |
|
32
|
|
|
$this->assertEquals('//matomotest-test-test.test/', $config3->MatomoTrackingURL); |
|
33
|
|
|
$this->assertEquals('1234', $config1->MatomoSiteId); |
|
34
|
|
|
|
|
35
|
|
|
//applied via SiteConfig |
|
36
|
|
|
$config4 = $this->objFromFixture(SiteConfig::class, 'good4'); |
|
37
|
|
|
//add trailing slash |
|
38
|
|
|
$config4->write(); |
|
39
|
|
|
$this->assertEquals('//matomotest-test-test.test/', $config4->MatomoTrackingURL); |
|
40
|
|
|
$this->assertEquals('1234', $config1->MatomoSiteId); |
|
41
|
|
|
|
|
42
|
|
|
//applied via SiteConfig |
|
43
|
|
|
$config5 = $this->objFromFixture(SiteConfig::class, 'bad1'); |
|
44
|
|
|
//add trailing slash |
|
45
|
|
|
$config5->write(); |
|
46
|
|
|
$this->assertEquals('//matomotest-test-test.test/', $config5->MatomoTrackingURL); |
|
47
|
|
|
$this->assertEquals('1234', $config1->MatomoSiteId); |
|
48
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testTrackingCode() |
|
52
|
|
|
{ |
|
53
|
|
|
$config1 = $this->objFromFixture(SiteConfig::class, 'good1'); |
|
54
|
|
|
$actual = (string)Matomo::tracking_code( |
|
55
|
|
|
$config1->MatomoTrackingURL, |
|
56
|
|
|
$config1->MatomoSiteId |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertRegExp('#var u="//matomotest-test-test.test/";#', $actual); |
|
60
|
|
|
$this->assertRegExp("#_paq\.push\(\['setTrackerUrl', u\+'matomo.php'\]\);#", $actual); |
|
61
|
|
|
$this->assertRegExp("#_paq\.push\(\['setSiteId', '1234'\]\);#", $actual); |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths