diff --git a/tests/MigrationTestCase.php b/tests/MigrationTestCase.php index 14ca53ed2..7b718ba54 100644 --- a/tests/MigrationTestCase.php +++ b/tests/MigrationTestCase.php @@ -32,13 +32,13 @@ */ class Doctrine_Migration_TestCase extends Doctrine_UnitTestCase { - const TABLES = array( - 'MigrationPhonenumber', - 'MigrationUser', - 'MigrationProfile', - ); - - protected $tables = self::TABLES; + public function prepareTables() + { + $this->tables[] = 'MigrationPhonenumber'; + $this->tables[] = 'MigrationUser'; + $this->tables[] = 'MigrationProfile'; + parent::prepareTables(); + } public function testMigration() { @@ -127,59 +127,4 @@ public function testMigrationClassNameInflected() $this->assertTrue($code); } } - - public function test_afterSuccessfullMigration_willSetMigratedVersionAsCurrentVersionInMysqlDB() - { - $connection = $this->openMysqlAdditionalConnection(); - $this->resetTablesOnConnection(self::TABLES, $connection); - - $migration = new Doctrine_Migration('migration_classes', $connection); - $migration->setCurrentVersion(3); - - $migration->migrate(4); - $this->assertEqual(4, $migration->getCurrentVersion()); - } - - public function test_afterFailedMigration_willKeepCurrentVersionInMysqlDB() - { - $connection = $this->openMysqlAdditionalConnection(); - $this->resetTablesOnConnection(self::TABLES, $connection); - - $migration = new Doctrine_Migration('migration_classes', $connection); - $migration->setCurrentVersion(0); - - try { - $migration->migrate(1); - - $this->fail('migration must fail'); - } catch (Doctrine_Migration_Exception $e) { - $this->assertEqual(0, $migration->getCurrentVersion()); - } - } -} - -class MigrationPhonenumber extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('phonenumber', 'string', 255); - } -} - -class MigrationUser extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('username', 'string', 255); - $this->hasColumn('password', 'string', 255); - } -} - -class MigrationProfile extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 255); - } } diff --git a/tests/models/MigrationPhonenumber.php b/tests/models/MigrationPhonenumber.php new file mode 100644 index 000000000..af55ef786 --- /dev/null +++ b/tests/models/MigrationPhonenumber.php @@ -0,0 +1,10 @@ +hasColumn('user_id', 'integer'); + $this->hasColumn('phonenumber', 'string', 255); + } +} diff --git a/tests/models/MigrationProfile.php b/tests/models/MigrationProfile.php new file mode 100644 index 000000000..8302b6751 --- /dev/null +++ b/tests/models/MigrationProfile.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 255); + } +} diff --git a/tests/models/MigrationUser.php b/tests/models/MigrationUser.php new file mode 100644 index 000000000..7c366179f --- /dev/null +++ b/tests/models/MigrationUser.php @@ -0,0 +1,10 @@ +hasColumn('username', 'string', 255); + $this->hasColumn('password', 'string', 255); + } +} diff --git a/tests/run.php b/tests/run.php index d1dd2c7ee..b458896b6 100644 --- a/tests/run.php +++ b/tests/run.php @@ -279,6 +279,7 @@ // Migration Tests $migration = new GroupTest('Migration Tests', 'migration'); $migration->addTestCase(new Doctrine_Migration_TestCase()); +$migration->addTestCase(new Doctrine_Migration_Mysql_TestCase()); $migration->addTestCase(new Doctrine_Migration_Base_TestCase()); $migration->addTestCase(new Doctrine_Migration_Diff_TestCase()); $test->addTestCase($migration);