You are here

protected function GTMBaseTestCase::submitContainers in GoogleTagManager 7.2

Add containers through user interface.

1 call to GTMBaseTestCase::submitContainers()
GTMBaseTestCase::testModule in tests/google_tag.base.test
Test the module.

File

tests/google_tag.base.test, line 155

Class

GTMBaseTestCase
Tests the Google Tag Manager.

Code

protected function submitContainers() {

  // Create and login an admin user.
  $role_id = $this
    ->drupalCreateRole(array(
    'access content',
    'administer google tag manager',
  ), 'admin user');
  $admin_user = $this
    ->drupalCreateUser();
  $admin_user->roles[$role_id] = 'admin user';
  user_save($admin_user);
  $this
    ->drupalLogin($admin_user);
  foreach ($this->variables as $key => $variables) {
    $edit = (array) $variables;
    unset($edit['status']);
    if (isset($edit['realm_list'])) {
      $realm = current($edit['realm_list']);
      $edit["realm_list[{$realm}]"] = $realm;
      unset($edit['realm_list']);
    }
    $this
      ->drupalGet('/admin/config/system/google_tag/add');
    $this
      ->drupalPost(NULL, $edit, 'Save');
    $text = 'Created @count snippet files for %container container based on configuration.';
    $args = array(
      '@count' => 3,
      '%container' => $variables->label,
    );
    $text = t($text, $args);
    $message = 'Found snippet confirmation message in page response';
    $this
      ->assertRaw($text, $message, $this->group);
    $text = 'Created @count snippet files for @container container based on configuration.';
    $args = array(
      '@count' => 3,
      '@container' => $variables->label,
    );
    $text = t($text, $args);
    $this
      ->assertText($text, $message, $this->group);
  }
}