/**
  * Add a new migration to this list.
  *
  * @param sfPropelMigration $migration
  *
  * @return sfPropelMigrations (this)
  */
 public function addMigration(sfPropelMigration $migration)
 {
     if (empty($this->migrations[$migration->getVersion()])) {
         $this->migrations[$migration->getVersion()] = $migration;
     }
     ksort($this->migrations);
     $this->rewind();
     return $this;
 }
 /**
  * Intializes a new migration.
  *
  * @throws RuntimeException
  *
  * @param string $name The human readable name for this migration.
  *
  * @return string The filename for the new migration.
  */
 public function initializeMigration($name)
 {
     $version = microtime(true) * 10000;
     $migration = new sfPropelMigration($version, $name);
     $skeleton = sfPropelMigrationSkeleton::getSkeleton($version);
     if (!is_dir($migration->getDirname())) {
         $fs = new sfFilesystem();
         $fs->mkdirs($migration->getDirname());
     }
     if (is_writable($migration->getDirname())) {
         if (file_put_contents($migration->getFullFilename(), $skeleton) === false) {
             throw new RuntimeException(self::EXCEPTION_MIGRATION_NOT_WRITTEN);
         }
     } else {
         throw new RuntimeException(self::EXCEPTION_MIGRATION_DIR_NOT_WRITABLE);
     }
     return $migration->getFilename();
 }
}
try {
    $propelMigration = sfPropelMigration::createInstanceFromFilename('invalid-file-name');
    $limeTest->fail('InvalidArgumentException was not thrown.');
} catch (InvalidArgumentException $e) {
    $limeTest->pass('InvalidArgumentException caught.');
    $limeTest->is($e->getMessage(), sfPropelMigration::EXCEPTION_INVALID_FILENAME, 'Correct Exception.');
}
try {
    $propelMigration = sfPropelMigration::createInstanceFromFilename(5);
    $limeTest->fail('InvalidArgumentException was not thrown.');
} catch (InvalidArgumentException $e) {
    $limeTest->pass('InvalidArgumentException caught.');
    $limeTest->is($e->getMessage(), sfPropelMigration::EXCEPTION_INVALID_FILENAME, 'Correct Exception.');
}
$propelMigration = new sfPropelMigration(1, 'valid-name');
$limeTest->isa_ok($propelMigration, 'sfPropelMigration', 'Created sfPropelMigration.');
$fixturesMigrationsDir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'sfPropelMigrationsPlugin' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'migrations';
sfConfig::set('sf_propelmigrationsplugin_migrationsdir', $fixturesMigrationsDir);
$limeTest->is(sfPropelMigrationsPluginConfiguration::getMigrationsDir(), $fixturesMigrationsDir, 'Configured MigrationsDirectory.');
try {
    $propelMigration = sfPropelMigration::createInstanceFromFilename($fixturesMigrationsDir . DIRECTORY_SEPARATOR . 'first_test_migration' . DIRECTORY_SEPARATOR . '12755561356512_first_test_migration.php');
    $limeTest->fail('InvalidArgumentException was not thrown.');
} catch (InvalidArgumentException $e) {
    $limeTest->pass('InvalidArgumentException caught.');
    $limeTest->is($e->getMessage(), sfPropelMigration::EXCEPTION_INVALID_FILENAME, 'Correct Exception.');
}
$propelMigration = sfPropelMigration::createInstanceFromFilename($fixturesMigrationsDir . DIRECTORY_SEPARATOR . 'first_test_migration' . DIRECTORY_SEPARATOR . '12755561356551_first_test_migration.php');
$limeTest->isa_ok($propelMigration, 'sfPropelMigration', 'Created sfPropelMigration.');
$limeTest->is($propelMigration->getVersion(), 12755561356551.0, 'Correct Version.');
$limeTest->is($propelMigration->getName(), 'first_test_migration', 'Correct Name.');