]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added unit test for checkMigrate with primary key + autoinc
authorVincent Petry <pvince81@owncloud.com>
Tue, 17 Jun 2014 13:07:36 +0000 (15:07 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 17 Jun 2014 13:23:18 +0000 (15:23 +0200)
Added unit test to make sure that checkMigrate() works when adding a
primary key and autoincrement column to a table schema.

tests/lib/db/migrator.php

index e9b986236b8970901b924aa994a579be8de23911..e94d550f836ffee5a7cbb7368b49100e211568cd 100644 (file)
@@ -119,4 +119,25 @@ class Migrator extends \PHPUnit_Framework_TestCase {
                        $this->assertTrue(true);
                }
        }
+
+       public function testAddingPrimaryKeyWithAutoIncrement() {
+               $startSchema = new Schema(array(), array(), $this->getSchemaConfig());
+               $table = $startSchema->createTable($this->tableName);
+               $table->addColumn('id', 'integer');
+               $table->addColumn('name', 'string');
+
+               $endSchema = new Schema(array(), array(), $this->getSchemaConfig());
+               $table = $endSchema->createTable($this->tableName);
+               $table->addColumn('id', 'integer', array('autoincrement' => true));
+               $table->addColumn('name', 'string');
+               $table->setPrimaryKey(array('id'));
+
+               $migrator = $this->getMigrator();
+               $migrator->migrate($startSchema);
+
+               $migrator->checkMigrate($endSchema);
+               $migrator->migrate($endSchema);
+
+               $this->assertTrue(true);
+       }
 }