diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php index a8787cc5ee..f596684d92 100644 --- a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php +++ b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php @@ -26,11 +26,12 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true); + $doNotTrack = true, $disableCookies = false, $trackNoScript = true); $expected = "<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); // you can set up to 5 custom variables for each visitor _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); @@ -50,7 +51,33 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> -<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> +<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1&rec=1" style="border:0;" alt="" /></p></noscript> +<!-- End Piwik Code --> +"; + + $this->assertEquals($expected, $jsTag); + } + + public function testJavascriptTrackingCode_noScriptTrackingDisabled_defaultTrackingCode() + { + $generator = new TrackerCodeGenerator(); + + $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik'); + + $expected = "<!-- Piwik --> +<script type="text/javascript"> + var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//localhost/piwik/"; + _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setSiteId', '1']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + })(); +</script> <!-- End Piwik Code --> "; @@ -78,6 +105,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); // you can set up to 5 custom variables for each visitor _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); @@ -97,7 +125,6 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> -<noscript><p><img src="https://localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code --> "; @@ -125,6 +152,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); // you can set up to 5 custom variables for each visitor _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); @@ -145,7 +173,6 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> -<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code --> "; @@ -169,6 +196,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); @@ -180,7 +208,6 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase })(); </script> <script type='text/javascript' src="//localhost/piwik/piwik.js"></script> -<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code --> "; @@ -206,6 +233,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = '<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; + // tracker methods like "setCustomDimension" should be called before "trackPageView" _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); // you can set up to 5 custom variables for each visitor _paq.push(["setCustomVariable", 1, "abc\"def", "abc\"def", "visit"]); @@ -223,7 +251,6 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'piwik.js\'; s.parentNode.insertBefore(g,s); })(); </script> -<noscript><p><img src="//abc"def/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code --> '; |