/**
  * @test
  */
 public function findAllReturnsResultsInAscendingVersionOrder()
 {
     $this->repository->add(new MigrationStatus('zyx', MigrationStatus::DIRECTION_DOWN, new \DateTime()));
     $this->repository->add(new MigrationStatus('abc', MigrationStatus::DIRECTION_UP, new \DateTime()));
     $this->repository->add(new MigrationStatus('mnk', MigrationStatus::DIRECTION_DOWN, new \DateTime()));
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $expectedVersionOrder = array('abc', 'mnk', 'zyx');
     /** @var MigrationStatus $status */
     $i = 0;
     foreach ($this->repository->findAll() as $status) {
         $this->assertEquals($expectedVersionOrder[$i], $status->getVersion());
         $i++;
     }
 }
 /**
  * List available and applied migrations
  *
  * @return void
  * @see typo3.typo3cr.migration:node:listavailablemigrations
  */
 public function migrationStatusCommand()
 {
     $this->outputLine();
     $availableMigrations = $this->migrationFactory->getAvailableMigrationsForCurrentConfigurationType();
     if (count($availableMigrations) === 0) {
         $this->outputLine('No migrations available.');
         $this->quit();
     }
     $appliedMigrations = $this->migrationStatusRepository->findAll();
     $appliedMigrationsDictionary = array();
     /** @var $appliedMigration MigrationStatus */
     foreach ($appliedMigrations as $appliedMigration) {
         $appliedMigrationsDictionary[$appliedMigration->getVersion()][] = $appliedMigration;
     }
     $tableRows = array();
     foreach ($availableMigrations as $version => $migration) {
         $migrationUpConfigurationComments = $this->migrationFactory->getMigrationForVersion($version)->getUpConfiguration()->getComments();
         if (isset($appliedMigrationsDictionary[$version])) {
             $applicationInformation = $this->phraseMigrationApplicationInformation($appliedMigrationsDictionary[$version]);
             if ($applicationInformation !== '') {
                 $migrationUpConfigurationComments .= PHP_EOL . '<b>Applied:</b>' . PHP_EOL . $applicationInformation;
             }
         }
         $tableRows[] = array($version, $migration['formattedVersionNumber'], $migration['package']->getPackageKey(), wordwrap($migrationUpConfigurationComments, 60));
     }
     $this->outputLine('<b>Available migrations</b>');
     $this->outputLine();
     $this->output->outputTable($tableRows, array('Version', 'Date', 'Package', 'Comments'));
 }