Exemplo n.º 1
0
 public function testGetScriptWithApiClient()
 {
     // Arrange
     $gaRenderer = new GoogleUniversalAnalytics(['walter' => 1, 'bernard' => 0]);
     $gaRenderer->setApiClientInclusion(true);
     // Act
     $script = $gaRenderer->getScript(true);
     // Assert
     $this->assertSame("<script src=\"//www.google-analytics.com/cx/api.js\"></script>\n<script>\n(function(){\n    ga(function(tracker) {\n        cxApi.setChosenVariation(1, 'walter');\n        tracker.send('event', 'PhpAb', 'walter', {'nonInteraction': 1});\n    });\n})();\n(function(){\n    ga(function(tracker) {\n        cxApi.setChosenVariation(0, 'bernard');\n        tracker.send('event', 'PhpAb', 'bernard', {'nonInteraction': 1});\n    });\n})();\n</script>", $script);
 }