/**
  * @covers BWP_Framework_Migration_Factory::create_migrations
  */
 public function test_create_migrations_correctly_and_in_correct_order()
 {
     $fixture_path = dirname(__FILE__) . '/fixtures/migrations';
     $migration_filenames = array('invalid.php', '10400.php', '110400.php', '10100_10400.php', '10100_10400-beta1.php', '10100-beta1_10400.php', '10100-beta1_10400-rc1.php');
     $migration_files = array();
     foreach ($migration_filenames as $filename) {
         $migration_files[$filename] = file_get_contents($fixture_path . '/' . $filename);
     }
     $migration_path = 'path/to/plugin/migrations';
     $fs_root = vfsStream::setup($migration_path);
     vfsStream::create($migration_files, $fs_root->getChild($migration_path));
     $this->plugin->plugin_file = vfsStream::url('path/to/plugin/bwp-plugin.php');
     $migrations = array();
     foreach (BWP_Framework_Migration_Factory::create_migrations($this->plugin) as $index => $migration) {
         $migrations[] = array($migration->get_previous_version(), $migration->get_version());
     }
     $this->assertEquals(array(array('1.1.0', '1.4.0-beta1'), array('1.1.0-beta1', '1.4.0-rc1'), array('1.1.0-beta1', '1.4.0'), array('1.1.0', '1.4.0'), array(null, '1.4.0'), array(null, '11.4.0')), $migrations);
 }
 /**
  * @since rev 157
  * @since 3.5.0 Load migration scripts automatically.
  */
 public function init_upgrade_plugin($from, $to)
 {
     // we do not allow upgrading from a non-existent $from version, except
     // when migrating legacy plugins
     if (!$from && empty($this->is_legacy)) {
         return;
     }
     // no migrations to execute
     if (!($migrations = BWP_Framework_Migration_Factory::create_migrations($this))) {
         return;
     }
     foreach ($migrations as $migration) {
         // do not migrate if the migrate-from version is already up-to-date
         if (version_compare($from, $migration->get_version(), '>=')) {
             continue;
         }
         // OR if the migrate-from version does not equal to the
         // specified one if any.
         if ($migration->get_previous_version() && $from !== $migration->get_previous_version()) {
             continue;
         }
         // migrate now
         $migration->up();
     }
 }