From 5897f6d1dda7cc0bfa9f5de7ec437dfba60fa8d1 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Sat, 13 Apr 2024 18:07:48 +0200 Subject: [PATCH] fixup! fix: Database Migration does set current version in DB #98 --- tests/MigrationTestCase.php | 43 ++++++------------------------------- tests/run.php | 1 + 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/tests/MigrationTestCase.php b/tests/MigrationTestCase.php index 310fa237a..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,33 +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()); - } - } } 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);