You are here

function SchemaTest::checkSchemaComment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/SchemaTest.php \Drupal\system\Tests\Database\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/modules/system/src/Tests/Database/SchemaTest.php
Tests database interactions.

File

core/modules/system/src/Tests/Database/SchemaTest.php, line 408
Contains \Drupal\system\Tests\Database\SchemaTest.

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\system\Tests\Database

Code

function checkSchemaComment($description, $table, $column = NULL) {
  if (method_exists(Database::getConnection()
    ->schema(), 'getComment')) {
    $comment = Database::getConnection()
      ->schema()
      ->getComment($table, $column);

    // The schema comment truncation for mysql is different.
    if (Database::getConnection()
      ->databaseType() == 'mysql') {
      $max_length = $column ? 255 : 60;
      $description = Unicode::truncate($description, $max_length, TRUE, TRUE);
    }
    $this
      ->assertEqual($comment, $description, 'The comment matches the schema description.');
  }
}