<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; # load fixtures of this plugin $propelData->loadData(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsPlugin/data/fixtures'); $limeTest = new lime_test(12, new lime_output_color()); $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.'); $propelMigrator = new sfPropelMigrator(); $migrations = $propelMigrator->getMigrations(); $limeTest->isa_ok($migrations, 'sfPropelMigrations', 'Got sfPropelMigrations.'); $limeTest->is(count($migrations), 3, 'Three test migrations found.'); // using Iterator to test content of list $migrations->rewind(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'First Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561356551.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'first_test_migration', 'Correct Name.'); $migrations->next(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'Third Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561453219.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'third_test_migration', 'Correct Name.'); $migrations->next(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'Second Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561493219.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'second_test_migration', 'Correct Name.');
require_once dirname(__FILE__) . '/../bootstrap/task.php'; # load fixtures of this plugin $propelData->loadData(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsPlugin/data/fixtures'); $limeTest = new lime_test(7, new lime_output_color()); $fixturesMigrationsDir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'sfPropelMigrationsPlugin' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'no-migrations' . DIRECTORY_SEPARATOR; sfConfig::set('sf_propelmigrationsplugin_migrationsdir', $fixturesMigrationsDir); $limeTest->is(sfPropelMigrationsPluginConfiguration::getMigrationsDir(), $fixturesMigrationsDir, 'Configured MigrationsDirectory.'); $task = new sfPropelInitMigrationTask($dispatcher, $formatter); chmod($fixturesMigrationsDir, 0555); $task->run(array('"Test Migration"'), array()); $logs = $logger->getLogEntries(); $limeTest->like($logs[1], '/' . sfPropelMigrator::EXCEPTION_MIGRATION_DIR_NOT_WRITABLE . '/', 'Directory currently not writable.'); chmod($fixturesMigrationsDir, 0775); $task->run(array('"Test Migration"'), array()); $logs = $logger->getLogEntries(); $limeTest->like($logs[3], '/file\\+.*Test_Migration.php/', 'File was written.'); $propelMigrator = new sfPropelMigrator(); $propelMigration = $propelMigrator->getMigrations()->current(); $limeTest->is(count($propelMigrator->getMigrations()), 1, 'Found new migration.'); $limeTest->is($propelMigration->getName(), 'Test_Migration', 'Correct name.'); $content = file_get_contents($propelMigration->getFullFilename()); $limeTest->is($content, sfPropelMigrationSkeleton::getSkeleton($propelMigration->getVersion()), 'Skeleton was written correctly.'); require_once $propelMigration->getFullFilename(); $className = 'sfMigration_' . $propelMigration->getVersion(); $migration = new $className(); $limeTest->isa_ok($migration, $className, 'Created sfMigration instance.'); // clean up the mess, we did :-) $files = sfFinder::type('file')->name('/^\\d{14}.*\\.php$/')->maxdepth(0)->in($fixturesMigrationsDir . DIRECTORY_SEPARATOR . 'Test_Migration' . DIRECTORY_SEPARATOR); $task->getFilesystem()->remove($files); $task->getFilesystem()->remove($fixturesMigrationsDir . DIRECTORY_SEPARATOR . 'Test_Migration' . DIRECTORY_SEPARATOR);