You are here

public function RegressionTest::testRegression_310447 in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php \Drupal\KernelTests\Core\Database\RegressionTest::testRegression_310447()

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

File

core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php, line 22

Class

RegressionTest
Regression tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testRegression_310447() {

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