function SchemaTest::checkSchemaComment

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::checkSchemaComment()
  2. 10 core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkSchemaComment()
  3. 10 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::checkSchemaComment()
  4. 10 core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::checkSchemaComment()
  5. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkSchemaComment()
  6. 11.x core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::checkSchemaComment()
  7. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::checkSchemaComment()

Checks that a table or column comment matches a given description.

Parameters

$description: The asserted description.

$table: The table to test.

$column: Optional column to test.

1 call to SchemaTest::checkSchemaComment()
SchemaTest::testSchema in core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
Tests database interactions.

File

core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php, line 386

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function checkSchemaComment($description, $table, $column = NULL) {
    if (method_exists($this->schema, 'getComment')) {
        $comment = $this->schema
            ->getComment($table, $column);
        // The schema comment truncation for mysql is different.
        if ($this->connection
            ->databaseType() === 'mysql') {
            $max_length = $column ? 255 : 60;
            $description = Unicode::truncate($description, $max_length, TRUE, TRUE);
        }
        $this->assertEquals($description, $comment, 'The comment matches the schema description.');
    }
}

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