From 6192e19f60cd6e0a7f4c5841271ca9caf5eeafa4 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 23 Feb 2010 05:07:18 +0000 Subject: #720620 by andypost: Fixed indexExists() for pgsql and sqlite does not prefix tablename. --- modules/simpletest/tests/schema.test | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'modules/simpletest') diff --git a/modules/simpletest/tests/schema.test b/modules/simpletest/tests/schema.test index 1cf48e933..7f7571ef9 100644 --- a/modules/simpletest/tests/schema.test +++ b/modules/simpletest/tests/schema.test @@ -61,8 +61,22 @@ class SchemaTestCase extends DrupalWebTestCase { // The insert should fail again. $this->assertFalse($this->tryInsert(), t('Insert without a default failed.')); + // Test for fake index. + $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); + $this->assertFalse($index_exists, t('Fake index does not exists')); + // Add index. + db_add_index('test_table', 'test_field', array('test_field')); + // Test for created index. + $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); + $this->assertTrue($index_exists, t('Index created.')); + // Rename the table. db_rename_table('test_table', 'test_table2'); + + // Index should be renamed. + $index_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field'); + $this->assertTrue($index_exists, t('Index was renamed.')); + // We need the default so that we can insert after the rename. db_field_set_default('test_table2', 'test_field', 0); $this->assertFalse($this->tryInsert(), t('Insert into the old table failed.')); @@ -129,17 +143,6 @@ class SchemaTestCase extends DrupalWebTestCase { } } - /** - * Test index status. - */ - function testCheckIndex() { - $node_changed_index = Database::getConnection()->schema()->indexExists('node', 'node_changed'); - $this->assertTrue($node_changed_index, t('Node index exists')); - - $node_fake_index = Database::getConnection()->schema()->indexExists('node', 'node_not_exists'); - $this->assertFalse($node_fake_index, t('Fake index does not exists')); - } - /** * Tests creating unsigned columns and data integrity thereof. */ -- cgit v1.2.3