Skip to content

Commit b734a52

Browse files
committed
Added testDropPrimaryKey() to ForgeTest
1 parent b7d07f2 commit b734a52

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/system/Database/Live/ForgeTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,4 +1372,40 @@ public function testAddTextColumnWithConstraint()
13721372

13731373
$this->assertFalse($this->db->fieldExists('text_with_constraint', 'user'));
13741374
}
1375+
1376+
public function testDropPrimaryKey()
1377+
{
1378+
$this->forge->dropTable('forge_test_users', true);
1379+
1380+
$this->forge->addField([
1381+
'id' => [
1382+
'type' => 'INTEGER',
1383+
'constraint' => 11,
1384+
],
1385+
'second_id' => [
1386+
'type' => 'VARCHAR',
1387+
'constraint' => 50,
1388+
],
1389+
'name' => [
1390+
'type' => 'VARCHAR',
1391+
'constraint' => 255,
1392+
],
1393+
]);
1394+
$primaryKeys = ['id', 'second_id'];
1395+
$this->forge->addPrimaryKey($primaryKeys);
1396+
$this->forge->createTable('forge_test_users', true);
1397+
1398+
$indexes = $this->db->getIndexData('forge_test_users');
1399+
1400+
$this->assertCount(1, $indexes);
1401+
$this->assertSame($primaryKeys, current($indexes)->fields);
1402+
1403+
$this->forge->dropPrimaryKey('forge_test_users');
1404+
1405+
$indexes = $this->db->getIndexData('forge_test_users');
1406+
1407+
$this->assertCount(0, $indexes);
1408+
1409+
$this->forge->dropTable('forge_test_users', true);
1410+
}
13751411
}

0 commit comments

Comments
 (0)