// Test for fake index and test for the boolean result of indexExists().
$index_exists =
$this->schema->
indexExists('test_table', 'test_field'
);
$this->
assertFalse($index_exists, 'Fake index does not exist'
);
// Add index.
$this->schema->
addIndex('test_table', 'test_field',
['test_field'
],
$table_specification);
// Test for created index and test for the boolean result of indexExists().
$index_exists =
$this->schema->
indexExists('test_table', 'test_field'
);
$this->
assertTrue($index_exists, 'Index created.'
);
// Rename the table.
$this->
assertNull($this->schema->
renameTable('test_table', 'test_table2'
));
// Index should be renamed.
$index_exists =
$this->schema->
indexExists('test_table2', 'test_field'
);
$this->
assertTrue($index_exists, 'Index was renamed.'
);
// We need the default so that we can insert after the rename.
$this->schema->
changeField('test_table2', 'test_field', 'test_field',
['type' => 'int', 'not null' => TRUE, 'default' => 0
]);
$this->
assertFalse($this->
tryInsert(), 'Insert into the old table failed.'
);
$this->
assertTrue($this->
tryInsert('test_table2'
), 'Insert into the new table succeeded.'
);
// We should have successfully inserted exactly two rows.