Skip to content

Commit

Permalink
fixup! fix: Database Migration does set current version in DB Friends…
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Jul 3, 2024
1 parent 88cfed5 commit 5897f6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
43 changes: 7 additions & 36 deletions tests/MigrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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());
}
}
}
1 change: 1 addition & 0 deletions tests/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5897f6d

Please sign in to comment.