summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-06-17 15:07:36 +0200
committerVincent Petry <pvince81@owncloud.com>2014-06-17 15:23:18 +0200
commitffdc1c2fcfd3fe05bd8d5b58839d3610ece0a03e (patch)
treee531fb89e38d746fc22a886a949541aeb9a3f61c /tests
parent7aa11b436145b9b5d1cef2fb88725d81729aab20 (diff)
downloadnextcloud-server-ffdc1c2fcfd3fe05bd8d5b58839d3610ece0a03e.tar.gz
nextcloud-server-ffdc1c2fcfd3fe05bd8d5b58839d3610ece0a03e.zip
Added unit test for checkMigrate with primary key + autoinc
Added unit test to make sure that checkMigrate() works when adding a primary key and autoincrement column to a table schema.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db/migrator.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index e9b986236b8..e94d550f836 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -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);
+ }
}