You are here

public function NodeFieldMultilingualTest::testMultilingualDisplaySettings in Drupal 8

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

Tests multilingual field display settings.

File

core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php, line 114

Class

NodeFieldMultilingualTest
Tests multilingual support for fields.

Namespace

Drupal\Tests\node\Functional

Code

public function testMultilingualDisplaySettings() {

  // Create "Basic page" content.
  $title_key = 'title[0][value]';
  $title_value = $this
    ->randomMachineName(8);
  $body_key = 'body[0][value]';
  $body_value = $this
    ->randomMachineName(16);

  // Create node to edit.
  $edit = [];
  $edit[$title_key] = $title_value;
  $edit[$body_key] = $body_value;
  $this
    ->drupalPostForm('node/add/page', $edit, t('Save'));

  // Check that the node exists in the database.
  $node = $this
    ->drupalGetNodeByTitle($edit[$title_key]);
  $this
    ->assertNotEmpty($node, 'Node found in database.');

  // Check if node body is showed.
  $this
    ->drupalGet('node/' . $node
    ->id());
  $body = $this
    ->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]//div[contains(concat(" ", normalize-space(@class), " "), :content-class)]/descendant::p', [
    ':node-class' => ' node ',
    ':content-class' => 'node__content',
  ]);
  $this
    ->assertEqual($body[0]
    ->getText(), $node->body->value, 'Node body found.');
}