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.
This commit is contained in:
Vincent Petry 2014-06-17 15:07:36 +02:00
parent 7aa11b4361
commit ffdc1c2fcf
1 changed files with 21 additions and 0 deletions

View 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);
}
}