function DriverSpecificSchemaTestBase::testInvalidUniqueKeyColumnsOnAddUniqueKey

Tests invalid unique key columns on add unique key.

Attributes

#[IgnoreDeprecations]

File

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

Class

DriverSpecificSchemaTestBase
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidUniqueKeyColumnsOnAddUniqueKey() : 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,
      ],
    ],
  ]);
  $this->schema
    ->addUniqueKey('table_with_invalid_unique_key', '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.