google_tag.norealm.test in GoogleTagManager 7
File
tests/google_tag.norealm.test
View source
<?php
class GTMNoRealmTestCase extends GTMBaseTestCase {
public static function getInfo() {
return array(
'name' => 'Google Tag Manager :: Standard',
'description' => 'Tests the Google Tag Manager with no variable realm',
'group' => 'Google tag',
);
}
protected function setUp() {
parent::setUp(array(
'google_tag',
));
}
protected function createData() {
$this->variables = (object) ($variables = array(
'google_tag_container_id' => 'GTM-norealm',
'google_tag_environment_id' => 'env-6',
'google_tag_environment_token' => 'nnnnnnnnnnnnnnnnnnnnn',
'google_tag_include_environment' => '1',
));
array_walk($variables, function ($value, $key) {
variable_set($key, $value);
});
google_tag_assets_create();
}
protected function checkSnippetFiles() {
$realm_name = $key_name = '';
foreach ($this->types as $type) {
$url = "{$this->basePath}/google_tag/{$realm_name}google_tag.{$key_name}{$type}.js";
$contents = @file_get_contents($url);
$function = "verify{$type}Snippet";
$this
->{$function}($contents, $this->variables);
}
}
protected function checkPageResponse() {
parent::checkPageResponse();
$this
->drupalGet('');
$realm_name = $key_name = '';
foreach ($this->types as $type) {
$uri = "{$this->basePath}/google_tag/{$realm_name}google_tag.{$key_name}{$type}.js";
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
$realpath = $wrapper
->getExternalUrl($uri);
$function = "verify{$type}Tag";
$this
->{$function}($realpath, $this->variables);
}
else {
}
}
}
}