function DriverSpecificSchemaTestBase::testInvalidUniqueKeyColumnsOnCreateTable

Tests invalid unique key columns on create table.

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php, line 942

Class

DriverSpecificSchemaTestBase
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidUniqueKeyColumnsOnCreateTable() : void {
  $this->expectUserDeprecationMessage("Specification of unique keys with column length is deprecated in drupal:12.1.0 and will throw a SchemaException from drupal:13.0.0. Specify full columns for an unique key, or use an index for columns with partial length. See https://www.drupal.org/node/3375071");
  // Test with partial column length.
  $this->schema
    ->createTable('table_with_invalid_unique_key', [
    'description' => 'Table with partial column length unique key.',
    'fields' => [
      'test_field_1' => [
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
      ],
    ],
    'unique keys' => [
      'test_unique_key' => [
        [
          'test_field_1',
          10,
        ],
      ],
    ],
  ]);
}

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