You are here

public function DomainConfigOverriderTest::testDomainConfigOverrider in Domain Access 8

Tests that domain-specific variable loading works.

File

domain_config/tests/src/Functional/DomainConfigOverriderTest.php, line 17

Class

DomainConfigOverriderTest
Tests the domain config system.

Namespace

Drupal\Tests\domain_config\Functional

Code

public function testDomainConfigOverrider() {

  // No domains should exist.
  $this
    ->domainTableIsEmpty();

  // Create five new domains programmatically.
  $this
    ->domainCreateTestDomains(5);

  // Get the domain list.
  $domains = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->loadMultiple();

  // Except for the default domain, the page title element should match what
  // is in the override files.
  // With a language context, based on how we have our files setup, we
  // expect the following outcomes:
  // - example.com name = 'Drupal' for English, 'Drupal' for Spanish.
  // - one.example.com name = 'One' for English, 'Drupal' for Spanish.
  // - two.example.com name = 'Two' for English, 'Dos' for Spanish.
  // - three.example.com name = 'Drupal' for English, 'Drupal' for Spanish.
  // - four.example.com name = 'Four' for English, 'Four' for Spanish.
  foreach ($domains as $domain) {

    // Test the login page, because our default homepages do not exist.
    foreach ($this->langcodes as $langcode => $language) {
      $path = $domain
        ->getPath() . $langcode . '/user/login';
      $this
        ->drupalGet($path);
      if ($domain
        ->isDefault()) {
        $this
          ->assertRaw('<title>Log in | Drupal</title>', 'Loaded the proper site name.');
      }
      else {
        $this
          ->assertRaw('<title>Log in | ' . $this
          ->expectedName($domain, $langcode) . '</title>', 'Loaded the proper site name.' . '<title>Log in | ' . $this
          ->expectedName($domain, $langcode) . '</title>');
      }
    }
  }
}