3 namespace Drupal\KernelTests\Core\Database;
6 * Regression tests cases for the database layer.
10 class RegressionTest extends DatabaseTestBase {
17 public static $modules = ['node', 'user'];
20 * Ensures that non-ASCII UTF-8 data is stored in the database properly.
22 public function testRegression_310447() {
23 // That's a 255 character UTF-8 string.
24 $job = str_repeat("é", 255);
27 'name' => $this->randomMachineName(),
32 $from_database = db_query('SELECT job FROM {test} WHERE job = :job', [':job' => $job])->fetchField();
33 $this->assertSame($job, $from_database, 'The database handles UTF-8 characters cleanly.');
37 * Tests the db_table_exists() function.
39 public function testDBTableExists() {
40 $this->assertSame(TRUE, $this->connection->schema()->tableExists('test'), 'Returns true for existent table.');
41 $this->assertSame(FALSE, $this->connection->schema()->tableExists('nosuchtable'), 'Returns false for nonexistent table.');
45 * Tests the db_field_exists() function.
47 public function testDBFieldExists() {
48 $this->assertSame(TRUE, db_field_exists('test', 'name'), 'Returns true for existent column.');
49 $this->assertSame(FALSE, db_field_exists('test', 'nosuchcolumn'), 'Returns false for nonexistent column.');
53 * Tests the db_index_exists() function.
55 public function testDBIndexExists() {
56 $this->assertSame(TRUE, db_index_exists('test', 'ages'), 'Returns true for existent index.');
57 $this->assertSame(FALSE, db_index_exists('test', 'nosuchindex'), 'Returns false for nonexistent index.');