function SchemaTest::assertCollation

Same name in other branches
  1. 10 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::assertCollation()

Overrides DriverSpecificSchemaTestBase::assertCollation

File

core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php, line 36

Class

SchemaTest
Tests schema API for the MySQL driver.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

protected function assertCollation() : void {
    // Make sure that varchar fields have the correct collations.
    $columns = $this->connection
        ->query('SHOW FULL COLUMNS FROM {test_table}');
    foreach ($columns as $column) {
        if ($column->Field == 'test_field_string') {
            $string_check = $column->Collation;
        }
        if ($column->Field == 'test_field_string_ascii') {
            $string_ascii_check = $column->Collation;
        }
    }
    $this->assertMatchesRegularExpression('#^(utf8mb4_general_ci|utf8mb4_0900_ai_ci)$#', $string_check, 'test_field_string should have a utf8mb4_general_ci or a utf8mb4_0900_ai_ci collation, but it has not.');
    $this->assertSame('ascii_general_ci', $string_ascii_check, 'test_field_string_ascii should have a ascii_general_ci collation, but it has not.');
}

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