function DatabaseRegressionTestCase::testRegression_310447

Regression test for #310447.

Tries to insert non-ascii UTF-8 data in a database column and checks if its stored properly.

File

modules/simpletest/tests/database_test.test, line 3093

Class

DatabaseRegressionTestCase
Regression tests.

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.