function SchemaUniquePrefixedKeysIndexTestBase::testAddField

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::testAddField()

Tests adding a new field with UNIQUE key.

File

core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php, line 61

Class

SchemaUniquePrefixedKeysIndexTestBase
Tests adding UNIQUE keys to tables.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testAddField() : void {
    $field_spec = [
        'type' => 'varchar',
        'length' => 50,
    ];
    $keys_spec = [
        'unique keys' => [
            'field' => [
                [
                    'field',
                    10,
                ],
            ],
        ],
    ];
    $this->connection
        ->schema()
        ->addField('test', 'field', $field_spec, $keys_spec);
    $this->checkUniqueConstraintException('test', 'field');
}

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