You are here

function DomainSwitchingTest::testDomainSwitching in Domain Access 7.3

File

tests/domain.test, line 423
Simpletest for Domain Access.

Class

DomainSwitchingTest

Code

function testDomainSwitching() {

  // Create some domains.
  $result = $this
    ->domainCreateDomains();
  $_domain = domain_get_domain();

  // Are we currently on the primary domain?
  $default_id = domain_default_id();
  $this
    ->assertTrue($_domain['domain_id'] == $default_id, t('Primary domain loaded initially.'));

  // Get the domain list.
  $domains = domain_domains(TRUE);

  // Switch to each active domain.
  foreach ($domains as $domain) {
    domain_set_domain($domain['domain_id'], TRUE);
    $active = domain_get_domain();
    $this
      ->assertTrue($active['domain_id'] == $domain['domain_id'], t('Switched to domain %domain.', array(
      '%domain' => $domain['subdomain'],
    )));
  }

  // Reset the active domain.
  domain_reset_domain(TRUE);
  $active = domain_get_domain();
  $this
    ->assertTrue($active['domain_id'] == $_domain['domain_id'], t('Switched back to initial domain.'));
}