diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-08-28 09:33:55 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-08-28 09:33:55 +0300 |
commit | 77a6412ff7a8bdb2f23fb00a2d8ce22e7a35fcee (patch) | |
tree | 32100fa64ee556f1fd125751bb7c619dc73200bf /tests/javascript | |
parent | ba0a9d53f41a96c994d9bb1c8298d97c0400060c (diff) |
Split piwik.js into multiple files and provide a merged one (#10441)
refs #6106
Diffstat (limited to 'tests/javascript')
-rw-r--r-- | tests/javascript/index.php | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/javascript/index.php b/tests/javascript/index.php index 043a9ef8c1..c03d06ba22 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -21,6 +21,20 @@ try { $mysql = false; } +use \Piwik\Plugins\CustomPiwikJs\TrackerUpdater; +use \Piwik\Plugins\CustomPiwikJs\TrackingCode\JsTestPluginTrackerFiles; + +$targetFileName = '/tests/resources/piwik.test.js'; +$sourceFile = PIWIK_DOCUMENT_ROOT . TrackerUpdater::DEVELOPMENT_PIWIK_JS; +$targetFile = PIWIK_DOCUMENT_ROOT . $targetFileName; + +file_put_contents($targetFile, ''); + +$updater = new TrackerUpdater($sourceFile, $targetFile); +$updater->setTrackerFiles(new JsTestPluginTrackerFiles()); +$updater->checkWillSucceed(); +$updater->update(); + if(file_exists("stub.tpl")) { echo file_get_contents("stub.tpl"); } @@ -60,7 +74,7 @@ testTrackPageViewAsync(); ?> </script> <script src="../lib/q-1.4.1/q.js" type="text/javascript"></script> - <script src="../../js/piwik.js?rand=<?php echo $cacheBuster ?>" type="text/javascript"></script> + <script src="../..<?php echo $targetFileName ?>?rand=<?php echo $cacheBuster ?>" type="text/javascript"></script> <script src="../../plugins/Overlay/client/urlnormalizer.js" type="text/javascript"></script> <script src="piwiktest.js" type="text/javascript"></script> <link rel="stylesheet" href="assets/qunit.css" type="text/css" media="screen" /> @@ -1971,7 +1985,7 @@ function PiwikTest() { }); test("API methods", function() { - expect(70); + expect(71); equal( typeof Piwik.addPlugin, 'function', 'addPlugin' ); equal( typeof Piwik.addPlugin, 'function', 'addTracker' ); @@ -2039,6 +2053,7 @@ function PiwikTest() { equal( typeof tracker.trackGoal, 'function', 'trackGoal' ); equal( typeof tracker.trackLink, 'function', 'trackLink' ); equal( typeof tracker.trackPageView, 'function', 'trackPageView' ); + equal( typeof tracker.trackRequest, 'function', 'trackRequest' ); // content equal( typeof tracker.trackAllContentImpressions, 'function', 'trackAllContentImpressions' ); equal( typeof tracker.trackVisibleContentImpressions, 'function', 'trackVisibleContentImpressions' ); @@ -2997,7 +3012,7 @@ function PiwikTest() { // Calling undefined methods should generate an error function callNonExistingMethod() { - _paq.push(['NonExistingFunction should error and display the error in the console.']); + _paq.push(['NonExistingFunction should error and display the error in the console']); } function callNonExistingMethodWithParameter() { _paq.push(['NonExistingFunction should not error', 'this is a parameter']); @@ -3172,7 +3187,7 @@ if ($mysql) { }); test("tracking", function() { - expect(118); + expect(119); // Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL) var stopEvent = function (evt) { @@ -3351,6 +3366,9 @@ if ($mysql) { var visitorIdEnd = tracker.getVisitorId(); ok( visitorIdStart == visitorIdEnd, "tracker.getVisitorId() same at the start and end of process"); + // Tracker custom request + tracker.trackRequest('myFoo=bar&baz=1'); + // Custom variables tracker.storeCustomVariablesInCookie(); tracker.setCookieNamePrefix("PREFIX"); @@ -3495,7 +3513,7 @@ if ($mysql) { xhr.open("GET", "piwik.php?requests=" + getToken(), false); xhr.send(null); results = xhr.responseText; - equal( (/<span\>([0-9]+)\<\/span\>/.exec(results))[1], "36", "count tracking events" ); + equal( (/<span\>([0-9]+)\<\/span\>/.exec(results))[1], "37", "count tracking events" ); // firing callback ok( trackLinkCallbackFired, "trackLink() callback fired" ); @@ -3529,6 +3547,9 @@ if ($mysql) { ok( /DoTrack/.test( results ), "setDoNotTrack(false)" ); ok( ! /DoNotTrack/.test( results ), "setDoNotTrack(true)" ); + // custom tracking request + ok( /myFoo=bar&baz=1&idsite=1/.test( results ), "trackRequest sends custom parameters"); + // Test Custom variables ok( /SaveCustomVariableCookie.*&cvar=%7B%222%22%3A%5B%22cookiename2PAGE%22%2C%22cookievalue2PAGE%22%5D%7D.*&_cvar=%7B%221%22%3A%5B%22cookiename%22%2C%22cookievalue%22%5D%2C%222%22%3A%5B%22cookiename2%22%2C%22cookievalue2%22%5D%7D/.test(results), "test custom vars are set"); |