diff --git a/lib/Doctrine/Migration.php b/lib/Doctrine/Migration.php index 8dc18df8b..03a0bd38d 100644 --- a/lib/Doctrine/Migration.php +++ b/lib/Doctrine/Migration.php @@ -145,7 +145,7 @@ class Doctrine_Migration $e = explode('_', $fileName); $classMigrationNum = (int) $e[0]; - $loadedClasses[$classMigrationNum] = $fileName; + $loadedClasses[$classMigrationNum] = array('className' => $name, 'fileName' => $fileName); } $this->migrationClasses = $loadedClasses; @@ -228,7 +228,7 @@ class Doctrine_Migration $this->loadMigrationClasses(); $versions = array(); - foreach ($this->migrationClasses as $classMigrationNum => $fileName) { + foreach (array_keys($this->migrationClasses) as $classMigrationNum) { $versions[$classMigrationNum] = $classMigrationNum; } @@ -252,8 +252,10 @@ class Doctrine_Migration */ protected function getMigrationClass($num) { - foreach ($this->migrationClasses as $classMigrationNum => $fileName) { - if ($classMigrationNum === $num) { + foreach ($this->migrationClasses as $classMigrationNum => $info) { + $className = $info['className']; + + if ($classMigrationNum == $num) { return new $className(); } } diff --git a/tests/ManagerTestCase.php b/tests/ManagerTestCase.php index 3fe4a696a..e3a8cd9fb 100644 --- a/tests/ManagerTestCase.php +++ b/tests/ManagerTestCase.php @@ -55,6 +55,38 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(Doctrine::classify(Doctrine::tableize($name)), $name); + } + public function testDsnParser() + { + $mysql = 'mysql://user:pass@localhost/dbname'; + + // This is what is specified in the manul + // I think it should be this for parse_url() to work + // sqlite://full/unix/path/to/file.db + // It expects only // since it thinks it is parsing a url + // The problem after that is that the dns is not valid when being passed to PDO + $sqlite = 'sqlite:////full/unix/path/to/file.db'; + $sqlitewin = 'sqlite:///c:/full/windows/path/to/file.db'; + + $manager = Doctrine_Manager::getInstance(); + + try { + $manager->parseDsn($mysql); + } catch (Exception $e) { + $this->fail(); + } + + try { + $manager->parseDsn($sqlite); + } catch (Exception $e) { + $this->fail(); + } + + try { + $manager->parseDsn($sqlitewin); + } catch (Exception $e) { + $this->fail(); + } } public function prepareData() { } public function prepareTables() { } diff --git a/tests/MigrationTestCase.php b/tests/MigrationTestCase.php index 9e55aae26..50b00ebda 100644 --- a/tests/MigrationTestCase.php +++ b/tests/MigrationTestCase.php @@ -33,17 +33,17 @@ class Doctrine_Migration_TestCase extends Doctrine_UnitTestCase { public function testMigration() - { - // Upgrade one at a time + { + // New migration for the 'migration_classes' directory $migration = new Doctrine_Migration('migration_classes'); - $migration->migrate(0, 1); - $migration->migrate(1, 2); - // Then revert back to version 1 - $migration->migrate(2, 1); - $migration->migrate(1, 0); + // migrate to version 2 + $migration->migrate(2); - // Check to make sure the current version is 0 + // now migrate back to original version + $migration->migrate(0); + + // Make sure the current version is 0 $this->assertEqual($migration->getCurrentVersion(), 0); } } \ No newline at end of file