function SchemaTest::testSchemaTableKeyTooLargeException

Same name in other branches
  1. 10 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::testSchemaTableKeyTooLargeException()

Tests SchemaTableKeyTooLargeException.

File

core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php, line 256

Class

SchemaTest
Tests schema API for the MySQL driver.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

public function testSchemaTableKeyTooLargeException() : void {
    $this->expectException(SchemaTableKeyTooLargeException::class);
    $this->schema
        ->createTable('test_schema', [
        'description' => 'Tests SchemaTableKeyTooLargeException.',
        'fields' => [
            'id' => [
                'type' => 'varchar',
                'length' => 64,
                'not null' => TRUE,
            ],
            'id1' => [
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
            ],
            'id2' => [
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
            ],
            'id3' => [
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
            ],
            'id4' => [
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
            ],
            'id5' => [
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
            ],
        ],
        'primary key' => [
            'id',
        ],
        'indexes' => [
            'key1' => [
                'id1',
                'id2',
                'id3',
                'id4',
                'id5',
            ],
        ],
    ]);
}

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