You are here

public function NodeViewLanguageTest::testViewLanguage in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeViewLanguageTest.php \Drupal\Tests\node\Functional\NodeViewLanguageTest::testViewLanguage()

Tests the language extra field display.

File

core/modules/node/tests/src/Functional/NodeViewLanguageTest.php, line 29

Class

NodeViewLanguageTest
Tests the node language extra field display.

Namespace

Drupal\Tests\node\Functional

Code

public function testViewLanguage() {

  // Add Spanish language.
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Set language field visible.
  \Drupal::service('entity_display.repository')
    ->getViewDisplay('node', 'page', 'full')
    ->setComponent('langcode')
    ->save();

  // Create a node in Spanish.
  $node = $this
    ->drupalCreateNode([
    'langcode' => 'es',
  ]);
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->assertText('Spanish', 'The language field is displayed properly.');
}