function NodeFieldMultilingualTest::testMultilingualDisplaySettings

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php \Drupal\Tests\node\Functional\NodeFieldMultilingualTest::testMultilingualDisplaySettings()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php \Drupal\Tests\node\Functional\NodeFieldMultilingualTest::testMultilingualDisplaySettings()
  3. 11.x 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 126

Class

NodeFieldMultilingualTest
Tests multilingual support for fields.

Namespace

Drupal\Tests\node\Functional

Code

public function testMultilingualDisplaySettings() : void {
    // 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->drupalGet('node/add/page');
    $this->submitForm($edit, '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());
    $this->assertSession()
        ->elementTextEquals('xpath', "//article/div//p", $node->body->value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.