You are here

protected function GTMRealmTestCase::checkPageResponse in GoogleTagManager 7

Same name and namespace in other branches
  1. 7.2 tests/google_tag.realm.test \GTMRealmTestCase::checkPageResponse()

Inspect the page response.

Overrides GTMBaseTestCase::checkPageResponse

File

tests/google_tag.realm.test, line 128

Class

GTMRealmTestCase
Tests the Google Tag Manager for a site with realms.

Code

protected function checkPageResponse() {
  parent::checkPageResponse();

  // Remove global realm as no page response will use these values.
  $realms = variable_realm_list();
  unset($realms['global']);
  foreach ($realms as $realm_name => $realm_title) {
    $keys = variable_realm_keys($realm_name);
    foreach ($keys as $key_name => $key_title) {

      // The gtm_test module sets the realm from the query arguments.
      $this
        ->drupalGet('', $options = array(
        'query' => array(
          'name' => $realm_name,
          'key' => $key_name,
        ),
      ));
      $message = format_string('realm:key = @realm:@key', array(
        '@realm' => $realm_name,
        '@key' => $key_name,
      ));
      $this
        ->pass($message, $this->group);
      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[$key_name]);
        }
        else {

          // @todo
        }
      }
    }
  }
}