function SchemaTest::testIntrospectIndexSchema

Same name in this branch
  1. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::testIntrospectIndexSchema()
  2. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::testIntrospectIndexSchema()
Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::testIntrospectIndexSchema()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::testIntrospectIndexSchema()
  3. 10 core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::testIntrospectIndexSchema()
  4. 10 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::testIntrospectIndexSchema()
  5. 10 core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::testIntrospectIndexSchema()

@covers \Drupal\mysql\Driver\Database\mysql\Schema::introspectIndexSchema

File

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

Class

SchemaTest
Tests schema API for the MySQL driver.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

public function testIntrospectIndexSchema() : void {
    $table_specification = [
        'fields' => [
            'id' => [
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ],
            'test_field_1' => [
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ],
            'test_field_2' => [
                'type' => 'int',
                'default' => 0,
            ],
            'test_field_3' => [
                'type' => 'int',
                'default' => 0,
            ],
            'test_field_4' => [
                'type' => 'int',
                'default' => 0,
            ],
            'test_field_5' => [
                'type' => 'int',
                'default' => 0,
            ],
        ],
        'primary key' => [
            'id',
            'test_field_1',
        ],
        'unique keys' => [
            'test_field_2' => [
                'test_field_2',
            ],
            'test_field_3_test_field_4' => [
                'test_field_3',
                'test_field_4',
            ],
        ],
        'indexes' => [
            'test_field_4' => [
                'test_field_4',
            ],
            'test_field_4_test_field_5' => [
                'test_field_4',
                'test_field_5',
            ],
        ],
    ];
    $table_name = strtolower($this->getRandomGenerator()
        ->name());
    $this->schema
        ->createTable($table_name, $table_specification);
    unset($table_specification['fields']);
    $introspect_index_schema = new \ReflectionMethod(get_class($this->schema), 'introspectIndexSchema');
    $index_schema = $introspect_index_schema->invoke($this->schema, $table_name);
    $this->assertEquals($table_specification, $index_schema);
}

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