Tests for creating tables with composite primary keys
authorChuck Hagenbuch <chuck@horde.org>
Wed, 13 Jan 2010 04:20:48 +0000 (23:20 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Wed, 13 Jan 2010 04:32:04 +0000 (23:32 -0500)
framework/Db/test/Horde/Db/Adapter/MysqliTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php

index fdd5a3f..3ace11b 100644 (file)
@@ -515,6 +515,17 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('`foo` int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', $pkColumn->toSql());
     }
 
+    public function testCreateTableCompositePk()
+    {
+        $table = $this->_conn->createTable('testings', array('primaryKey' => array('a_id', 'b_id')));
+          $table->column('a_id', 'integer');
+          $table->column('b_id', 'integer');
+        $table->end();
+
+        $pk = $this->_conn->primaryKey('testings');
+        $this->assertEquals(array('a_id', 'b_id'), $pk->columns);
+    }
+
     public function testCreateTableForce()
     {
         $this->_createTestTable('sports');
index b2da708..c0fe67b 100644 (file)
@@ -535,6 +535,17 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('`foo` int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', $pkColumn->toSql());
     }
 
+    public function testCreateTableCompositePk()
+    {
+        $table = $this->_conn->createTable('testings', array('primaryKey' => array('a_id', 'b_id')));
+          $table->column('a_id', 'integer');
+          $table->column('b_id', 'integer');
+        $table->end();
+
+        $pk = $this->_conn->primaryKey('testings');
+        $this->assertEquals(array('a_id', 'b_id'), $pk->columns);
+    }
+
     public function testCreateTableForce()
     {
         $this->_createTestTable('sports');
index 75e2c51..79322c9 100644 (file)
@@ -435,6 +435,17 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('"foo" serial primary key', $pkColumn->toSql());
     }
 
+    public function testCreateTableCompositePk()
+    {
+        $table = $this->_conn->createTable('testings', array('primaryKey' => array('a_id', 'b_id')));
+          $table->column('a_id', 'integer');
+          $table->column('b_id', 'integer');
+        $table->end();
+
+        $pk = $this->_conn->primaryKey('testings');
+        $this->assertEquals(array('a_id', 'b_id'), $pk->columns);
+    }
+
     public function testCreateTableForce()
     {
         $this->_createTestTable('sports');
index 0edc58e..065fc55 100644 (file)
@@ -431,6 +431,17 @@ class Horde_Db_Adapter_Pdo_SqliteTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('"foo" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL', $pkColumn->toSql());
     }
 
+    public function testCreateTableCompositePk()
+    {
+        $table = $this->_conn->createTable('testings', array('primaryKey' => array('a_id', 'b_id')));
+          $table->column('a_id', 'integer');
+          $table->column('b_id', 'integer');
+        $table->end();
+
+        $pk = $this->_conn->primaryKey('testings');
+        $this->assertEquals(array('a_id', 'b_id'), $pk->columns);
+    }
+
     public function testCreateTableForce()
     {
         $this->_createTestTable('sports');