You are here

public function DomainTestCase::domainCreateDomains in Domain Access 7.3

Helper function to create domains.

Parameters

$subdomains: An array of subdomains to create.

$base: A base domain string, in the format 'example.com'.

Return value

An array of created domains.

12 calls to DomainTestCase::domainCreateDomains()
DomainCacheTest::testDomainPageCache in tests/domain.test
DomainConfTestCase::setUp in domain_conf/tests/domain_conf.test
On setup, install our module and create a default domain.
DomainCreateTest::testDomainCreate in tests/domain.test
DomainCreateTest::testDomainMacineNameLoad in tests/domain.test
DomainFilterTest::testDomainURLFilters in tests/domain.test

... See full list

File

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

Class

DomainTestCase
@file Simpletest for Domain Access.

Code

public function domainCreateDomains($subdomains = array(
  'one',
  'two',
  'three',
), $base = NULL) {
  $setup = drupal_map_assoc($subdomains);
  $base_domain = $base;
  if (empty($base_domain) && !empty($_SERVER['HTTP_HOST'])) {
    $base_domain = $_SERVER['HTTP_HOST'];
  }
  if (empty($base_domain)) {
    $base_domain = 'example.com';
  }
  $i = 0;
  $domains = array();
  foreach ($setup as $subdomain) {
    $record = array(
      'sitename' => $subdomain,
      'subdomain' => $subdomain . '.' . $base_domain,
      'valid' => 1,
      'is_default' => 0,
      'weight' => $i++,
      'scheme' => 'http',
    );
    $domains[$subdomain] = domain_save($record, $record);
  }
  return $domains;
}