function SchemaUniquePrefixedKeysIndexTestBase::testCreateTable

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

Tests UNIQUE keys put directly on the table definition.

File

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

Class

SchemaUniquePrefixedKeysIndexTestBase
Tests adding UNIQUE keys to tables.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testCreateTable() : void {
    $this->connection
        ->schema()
        ->createTable('test_unique', [
        'fields' => [
            'field' => [
                'type' => 'varchar',
                'length' => 50,
            ],
        ],
        'unique keys' => [
            'field' => [
                [
                    'field',
                    10,
                ],
            ],
        ],
    ]);
    $this->checkUniqueConstraintException('test_unique', 'field');
}

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