public function registerMigration($version, $class) { $this->ensureMigrationClassExists($class); $version = (string) $version; $class = (string) $class; if (isset($this->migrations[$version])) { throw MigrationException::duplicateMigrationVersion($version, get_class($this->migrations[$version])); } $version = new Version($this, $version, $class); $this->migrations[$version->getVersion()] = $version; ksort($this->migrations, SORT_STRING); return $version; }
/** * @see https://github.com/doctrine/migrations/issues/61 * @group regresion * @dataProvider provideTestMigrationNames */ public function testMigrateExecutesOlderVersionsThatHaveNetYetBeenMigrated(array $migrations) { foreach ($migrations as $key => $class) { $migration = new \Doctrine\DBAL\Migrations\Migration($this->config); $this->config->registerMigration($key, $class); $sql = $migration->migrate(); $this->assertCount(1, $sql, 'should have executed one migration'); } }