function DriverSpecificSchemaTestBase::testInvalidUniqueKeyColumnsOnAddField

Tests invalid unique key columns on add field.

Attributes

#[IgnoreDeprecations]

File

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

Class

DriverSpecificSchemaTestBase
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testInvalidUniqueKeyColumnsOnAddField() : 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
    ->addField('table_with_invalid_unique_key', 'new_test_field', [
    'type' => 'varchar',
    'length' => 50,
    'not null' => TRUE,
  ], [
    'unique keys' => [
      'test_unique_key' => [
        [
          'new_test_field',
          10,
        ],
      ],
    ],
  ]);
}

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