1 node.test public NodeMultiByteUtf8Test::testMultiByteUtf8()

Tests that multi-byte UTF-8 characters are stored and retrieved correctly.

File

core/modules/node/tests/node.test, line 3888
Tests for node.module.

Class

NodeMultiByteUtf8Test
Tests that multi-byte UTF-8 characters are stored and retrieved correctly.

Code

public function testMultiByteUtf8() {
  $connection = Database::getConnection();
  // On MySQL, this test will only run if 'charset' is set to 'utf8mb4' in
  // settings.php.
  if (!($connection->utf8mb4IsSupported() && $connection->utf8mb4IsActive())) {
    return;
  }
  $title = '�';
  $this->assertTrue(backdrop_strlen($title) < strlen($title), 'Title has multi-byte characters.');
  $node = $this->backdropCreateNode(array('title' => $title));
  $this->backdropGet('node/' . $node->nid);
  $result = $this->xpath('(//div[contains(@class, "l-top")])//h1');
  $this->assertEqual(trim((string) $result[0]), $title, 'The passed title was returned.');
}