You are here

function RegressionTest::testRegression_310447 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/RegressionTest.php \Drupal\system\Tests\Database\RegressionTest::testRegression_310447()

Ensures that non-ASCII UTF-8 data is stored in the database properly.

File

core/modules/system/src/Tests/Database/RegressionTest.php, line 27
Contains \Drupal\system\Tests\Database\RegressionTest.

Class

RegressionTest
Regression tests cases for the database layer.

Namespace

Drupal\system\Tests\Database

Code

function testRegression_310447() {

  // That's a 255 character UTF-8 string.
  $job = str_repeat("é", 255);
  db_insert('test')
    ->fields(array(
    'name' => $this
      ->randomMachineName(),
    'age' => 20,
    'job' => $job,
  ))
    ->execute();
  $from_database = db_query('SELECT job FROM {test} WHERE job = :job', array(
    ':job' => $job,
  ))
    ->fetchField();
  $this
    ->assertIdentical($job, $from_database, 'The database handles UTF-8 characters cleanly.');
}