Commit 54c3b98d authored by Jonathan.Wage's avatar Jonathan.Wage

Fixes.

parent 071febe9
......@@ -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();
}
}
......
......@@ -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() { }
......
......@@ -34,16 +34,16 @@ 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment