You are here

public function LocaleUpgradePathTestCase::testLocaleUpgradeDomain in Drupal 7

Test an upgrade with domain-based negotiation.

File

modules/simpletest/tests/upgrade/upgrade.locale.test, line 94

Class

LocaleUpgradePathTestCase
Upgrade test for locale.module.

Code

public function testLocaleUpgradeDomain() {

  // LANGUAGE_NEGOTIATION_DOMAIN.
  $this
    ->variable_set('language_negotiation', 3);
  $this
    ->assertTrue($this
    ->performUpgrade(), 'The upgrade was completed successfully.');

  // The home page should be in French.
  $this
    ->assertPageInLanguage('', 'fr');

  // The language switcher block should be displayed.
  $this
    ->assertRaw('block-locale-language', 'The language switcher block is displayed.');

  // The language switcher block should point to http://en.example.com.
  $language_links = $this
    ->xpath('//ul[contains(@class, :class)]/li/a', array(
    ':class' => 'language-switcher-locale-url',
  ));
  $found_english_link = FALSE;
  foreach ($language_links as $link) {
    if ((string) $link['href'] == 'http://en.example.com/') {
      $found_english_link = TRUE;
    }
  }
  $this
    ->assertTrue($found_english_link, 'The English link points to the correct domain.');

  // Both prefixes should be inactive.
  $this
    ->drupalGet('en');
  $this
    ->assertResponse(404);
  $this
    ->drupalGet('fr');
  $this
    ->assertResponse(404);
}