/** * Find all initialized migrations. * * @return sfPropelMigrations */ protected function loadMigrations() { $files = sfFinder::type('file')->name('/^\\d{14}.*\\.php$/')->maxdepth(1)->in(sfPropelMigrationsPluginConfiguration::getMigrationsDir()); if (empty($files)) { return array(); } else { $migrations = array(); foreach ($files as $key => $filename) { $migration = sfPropelMigration::createInstanceFromFilename($filename); $migrations[] = $migration; } return new sfPropelMigrations($migrations); } }
} 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.');