View source
<?php
namespace Drupal\system\Tests\Database;
class RegressionTest extends DatabaseTestBase {
public static $modules = array(
'node',
'user',
);
function testRegression_310447() {
$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.');
}
function testDBTableExists() {
$this
->assertIdentical(TRUE, db_table_exists('test'), 'Returns true for existent table.');
$this
->assertIdentical(FALSE, db_table_exists('nosuchtable'), 'Returns false for nonexistent table.');
}
function testDBFieldExists() {
$this
->assertIdentical(TRUE, db_field_exists('test', 'name'), 'Returns true for existent column.');
$this
->assertIdentical(FALSE, db_field_exists('test', 'nosuchcolumn'), 'Returns false for nonexistent column.');
}
function testDBIndexExists() {
$this
->assertIdentical(TRUE, db_index_exists('test', 'ages'), 'Returns true for existent index.');
$this
->assertIdentical(FALSE, db_index_exists('test', 'nosuchindex'), 'Returns false for nonexistent index.');
}
}