You are here

public function NodeViewTest::testMultiByteUtf8 in Drupal 8

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

Tests that we store and retrieve multi-byte UTF-8 characters correctly.

File

core/modules/node/tests/src/Functional/NodeViewTest.php, line 94

Class

NodeViewTest
Tests the node/{node} page.

Namespace

Drupal\Tests\node\Functional

Code

public function testMultiByteUtf8() {
  $title = '🐝';
  $this
    ->assertTrue(mb_strlen($title, 'utf-8') < strlen($title), 'Title has multi-byte characters.');
  $node = $this
    ->drupalCreateNode([
    'title' => $title,
  ]);
  $this
    ->drupalGet($node
    ->toUrl());
  $result = $this
    ->xpath('//span[contains(@class, "field--name-title")]');
  $this
    ->assertEqual($result[0]
    ->getText(), $title, 'The passed title was returned.');
}