You are here

function DomainTokenTest::testDomainTokens in Domain Access 7.3

Test the domain tokens.

File

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

Class

DomainTokenTest

Code

function testDomainTokens() {

  // Set the 'current' domain to the non-default domain 'three'.
  domain_set_domain($this->domains['three']['domain_id']);

  // Test the [domain:*] base tokens with a valid domain provided as data.
  $tokens = array(
    'id' => (string) $this->domains['one']['domain_id'],
    'machine-name' => 'one_example_com',
    'name' => 'one',
    'path' => domain_get_path($this->domains['one']),
    'url' => 'oneexamplecom',
    'hostname' => 'one.example.com',
    'subdomain' => 'one',
    // Deprecated tokens
    'machine_name' => 'one_example_com',
  );
  $data['domain'] = $this->domains['one'];
  $replacements = $this
    ->assertTokens('domain', $data, $tokens);

  // Ensure that the [domain:*] tokens do not replace anything if not
  // provided with a valid domain.
  $tokens = array(
    'id' => NULL,
    'name' => NULL,
  );
  $replacements = $this
    ->assertTokens('domain', array(), $tokens);

  // Test the [current-domain:*] tokens.
  $tokens = array(
    'id' => (string) $this->domains['three']['domain_id'],
    'machine-name' => 'three_example_com',
    'name' => 'three',
    'path' => domain_get_path($this->domains['three']),
    'url' => 'threeexamplecom',
    'hostname' => 'three.example.com',
    'subdomain' => 'three',
    // Deprecated tokens
    'machine_name' => 'three_example_com',
  );
  $replacements = $this
    ->assertTokens('current-domain', array(), $tokens);

  // Test the [default-domain:*] tokens.
  $tokens = array(
    'id' => '1',
    'name' => 'TestDomainSitename',
  );
  $replacements = $this
    ->assertTokens('default-domain', array(), $tokens);
}