function NodeFieldMultilingualTestCase::testMultilingualDisplaySettings

File

drupal/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php, line 118
Definition of Drupal\node\Tests\NodeFieldMultilingualTestCase.

Class

NodeFieldMultilingualTestCase
Functional test for multilingual fields.

Namespace

Drupal\node\Tests

Code

function testMultilingualDisplaySettings() {

  // Create "Basic page" content.
  $langcode = language_get_default_langcode('node', 'page');
  $title_key = "title";
  $title_value = $this
    ->randomName(8);
  $body_key = "body[{$langcode}][0][value]";
  $body_value = $this
    ->randomName(16);

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

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

  // Check if node body is showed.
  $this
    ->drupalGet("node/{$node->nid}");
  $body = $this
    ->xpath('//article[@id=:id]//div[@class=:class]/descendant::p', array(
    ':id' => 'node-' . $node->nid,
    ':class' => 'content',
  ));
  $this
    ->assertEqual(current($body), $node->body['en'][0]['value'], 'Node body found.');
}