You are here

public function HreflangTest::testHreflangMarkup in Hreflang 7

Test that hreflang link tags are added with URL detection.

File

./hreflang.test, line 45
Functional tests for Hreflang.

Class

HreflangTest
Functional tests for Hreflang.

Code

public function testHreflangMarkup() {
  global $base_url;

  // Enable language detection.
  $edit = array(
    'language[enabled][locale-url]' => 1,
  );
  $this
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
  $url = $base_url . '/';
  $path = variable_get('clean_url', 0) ? 'fr' : '?q=fr';
  $this
    ->drupalGet('');
  $this
    ->assertRaw('<link href="' . $url . $path . '" rel="alternate" hreflang="fr" />', 'French hreflang found on English page.');
  $this
    ->assertRaw('<link href="' . $url . '" rel="alternate" hreflang="en" />', 'English hreflang found on English page.');
  $this
    ->drupalGet('fr');
  $this
    ->assertRaw('<link href="' . $url . $path . '" rel="alternate" hreflang="fr" />', 'French hreflang found on French page.');
  $this
    ->assertRaw('<link href="' . $url . '" rel="alternate" hreflang="en" />', 'English hreflang found on French page.');
}