function SchemaTest::testRenameTableWithNewIndexNameEqualsTableName

Same name and namespace in other branches
  1. 10 core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::testRenameTableWithNewIndexNameEqualsTableName()

Tests renaming a table where the new index name is equal to the table name.

File

core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php, line 344

Class

SchemaTest
Tests schema API for the PostgreSQL driver.

Namespace

Drupal\Tests\pgsql\Kernel\pgsql

Code

public function testRenameTableWithNewIndexNameEqualsTableName() : void {
    // Special table names for colliding with the PostgreSQL new index name.
    $table_name_old = 'some_new_table_name__id__idx';
    $table_name_new = 'some_new_table_name';
    $table_specification = [
        'fields' => [
            'id' => [
                'type' => 'int',
                'default' => NULL,
            ],
        ],
        'indexes' => [
            'id' => [
                'id',
            ],
        ],
    ];
    $this->schema
        ->createTable($table_name_old, $table_specification);
    // Renaming the table can fail for PostgreSQL, when a new index name is
    // equal to the old table name.
    $this->schema
        ->renameTable($table_name_old, $table_name_new);
    $this->assertTrue($this->schema
        ->tableExists($table_name_new));
}

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