You are here

public function ContentTranslationContextualLinksTest::testContentTranslationContextualLinks in Drupal 8

Same name in this branch
  1. 8 core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::testContentTranslationContextualLinks()
  2. 8 core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\FunctionalJavascript\ContentTranslationContextualLinksTest::testContentTranslationContextualLinks()
Same name and namespace in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::testContentTranslationContextualLinks()
  2. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationContextualLinksTest::testContentTranslationContextualLinks()

Tests that a contextual link is available for translating a node.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php, line 108

Class

ContentTranslationContextualLinksTest
Tests that contextual links are available for content translation.

Namespace

Drupal\Tests\content_translation\Functional

Code

public function testContentTranslationContextualLinks() {

  // Create a node.
  $title = $this
    ->randomString();
  $this
    ->drupalCreateNode([
    'type' => $this->bundle,
    'title' => $title,
    'langcode' => 'en',
  ]);
  $node = $this
    ->drupalGetNodeByTitle($title);

  // Use a UI form submission to make the node type and field translatable.
  // This tests that caches are properly invalidated.
  $this
    ->drupalLogin($this->rootUser);
  $edit = [
    'entity_types[node]' => TRUE,
    'settings[node][' . $this->bundle . '][settings][language][language_alterable]' => TRUE,
    'settings[node][' . $this->bundle . '][translatable]' => TRUE,
    'settings[node][' . $this->bundle . '][fields][field_test_text]' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
  $this
    ->drupalLogout();

  // Check that the link leads to the translate page.
  $this
    ->drupalLogin($this->translator);
  $translate_link = 'node/' . $node
    ->id() . '/translations';
  $this
    ->drupalGet($translate_link);
  $this
    ->assertRaw(t('Translations of %label', [
    '%label' => $node
      ->label(),
  ]), 'The contextual link leads to the translate page.');
}