You are here

protected function GTMBaseTestCase::verifyNoScriptTag in GoogleTagManager 7.2

Same name and namespace in other branches
  1. 7 tests/google_tag.base.test \GTMBaseTestCase::verifyNoScriptTag()

Verify the tag in page response.

File

tests/google_tag.base.test, line 265

Class

GTMBaseTestCase
Tests the Google Tag Manager.

Code

protected function verifyNoScriptTag($realpath, $variables) {
  $xpath = '//div//noscript//iframe';
  $elements = $this
    ->xpath($xpath);
  $contents = (array) $elements[0]['src'];
  $contents = $contents[0];
  $status = strpos($contents, "id={$variables->container_id}") !== FALSE;
  $message = 'Found in noscript tag: container_id';
  $this
    ->assert($status, $message, $this->group);
  $status = strpos($contents, "gtm_preview={$variables->environment_id}") !== FALSE;
  $message = 'Found in noscript tag: environment_id';
  $this
    ->assert($status, $message, $this->group);
  $status = strpos($contents, "gtm_auth={$variables->environment_token}") !== FALSE;
  $message = 'Found in noscript tag: environment_token';
  $this
    ->assert($status, $message, $this->group);
}