diff --git a/tests/Migration/MysqlTestCase.php b/tests/Migration/MysqlTestCase.php new file mode 100644 index 00000000..955382bb --- /dev/null +++ b/tests/Migration/MysqlTestCase.php @@ -0,0 +1,76 @@ +. + */ + +/** + * Doctrine_Migration_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.doctrine-project.org + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Migration_Mysql_TestCase extends Doctrine_UnitTestCase +{ + private $migration; + + const TABLES = array( + 'MigrationPhonenumber', + 'MigrationUser', + 'MigrationProfile', + ); + + protected $tables = self::TABLES; + + public function setUp() + { + parent::setUp(); + + $connection = $this->openMysqlAdditionalConnection(); + $this->resetTablesOnConnection(self::TABLES, $connection); + + $this->migration = new Doctrine_Migration('migration_classes', $connection); + } + + public function test_afterSuccessfullMigration_willSetMigratedVersionAsCurrentVersionInMysqlDB() + { + $this->migration->setCurrentVersion(3); + + $this->migration->migrate(4); + + $this->assertEqual(4, $this->migration->getCurrentVersion()); + } + + public function test_afterFailedMigration_willKeepCurrentVersionInMysqlDB() + { + $this->migration->setCurrentVersion(0); + + try { + $this->migration->migrate(1); + + $this->fail('migration must fail'); + } catch (Doctrine_Migration_Exception $e) { + $this->assertEqual(0, $this->migration->getCurrentVersion()); + } + } +}