You are here

public function HreflangCommentTest::testHreflangComment in Hreflang 7

Tests that superfluous page=0 parameter is not added to hreflang links.

File

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

Class

HreflangCommentTest
Functional tests for Hreflang with Comment module.

Code

public function testHreflangComment() {

  // User to add language.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer languages',
    'create article content',
  ));
  $this
    ->drupalLogin($admin_user);

  // Add predefined language.
  $edit = array(
    'langcode' => 'fr',
  );
  $this
    ->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));

  // Enable language detection.
  $edit = array(
    'language[enabled][locale-url]' => 1,
  );
  $this
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));

  // Create a node.
  $edit = array(
    'title' => $this
      ->randomName(8),
    'body[' . LANGUAGE_NONE . '][0][value]' => $this
      ->randomName(16),
  );
  $this
    ->drupalPost('node/add/article', $edit, t('Save'));

  // Create a comment.
  $edit = array(
    'subject' => $this
      ->randomName(8),
    'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this
      ->randomName(16),
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Visit comment permalink page.
  $this
    ->clickLink(t('Permalink'));
  $this
    ->assertUrl('comment/1', array(
    'fragment' => 'comment-1',
  ));
  drupal_static_reset('language_list');
  drupal_static_reset('locale_url_outbound_alter');
  $languages = language_list();
  $this
    ->assertRaw('<link href="' . url('node/1', array(
    'absolute' => TRUE,
  )) . '" rel="alternate" hreflang="en" />');
  $this
    ->assertRaw('<link href="' . url('node/1', array(
    'absolute' => TRUE,
    'language' => $languages['fr'],
  )) . '" rel="alternate" hreflang="fr" />');
}