Checks that the language switch links behave properly.
function testLanguageSwitchLinks() {
// Create a Basic page in English and its translation in Spanish.
$node = $this
->createPage($this
->randomName(), $this
->randomName(), 'en');
$translation_es = $this
->createTranslation($node, $this
->randomName(), $this
->randomName(), 'es');
// Check that language switch links are correctly shown for languages
// we have translations for.
$this
->assertLanguageSwitchLinks($node, $translation_es);
$this
->assertLanguageSwitchLinks($translation_es, $node);
// Check that links to the displayed translation appear only in the language
// switcher block.
$this
->assertLanguageSwitchLinks($node, $node, FALSE, 'node');
$this
->assertLanguageSwitchLinks($node, $node, TRUE, 'block-language');
// Unpublish the Spanish translation to check that the related language
// switch link is not shown.
$this
->drupalLogin($this->admin_user);
$edit = array(
'status' => FALSE,
);
$this
->drupalPost("node/{$translation_es->nid}/edit", $edit, t('Save'));
$this
->drupalLogin($this->translator);
$this
->assertLanguageSwitchLinks($node, $translation_es, FALSE);
// Check that content translation links are shown even when no language
// negotiation is configured.
$this
->drupalLogin($this->admin_user);
$edit = array(
'language_interface[enabled][language-url]' => FALSE,
);
$this
->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
$this
->resetCaches();
$edit = array(
'status' => TRUE,
);
$this
->drupalPost("node/{$translation_es->nid}/edit", $edit, t('Save'));
$this
->drupalLogin($this->translator);
$this
->assertLanguageSwitchLinks($node, $translation_es, TRUE, 'node');
}