You are here

public function HreflangTest::testHreflangMarkupSession in Hreflang 7

Test that hreflang link tags are added with session detection.

File

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

Class

HreflangTest
Functional tests for Hreflang.

Code

public function testHreflangMarkupSession() {
  global $base_url;

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