Example #1
0
 /**
  * @param MigrationsMigrateCommand $command
  */
 public function migrationsMigrate(MigrationsMigrateCommand $command)
 {
     try {
         $status = $this->migrator->status();
         $nextAvailableVersion = $status->nextAvailableVersion();
         if ($nextAvailableVersion !== null) {
             $command->getIo()->writeLine('Starting migration to version <c2>' . $nextAvailableVersion->__toString() . '</c2>');
             $this->migrator->migrate();
             $command->getIo()->writeLine('The migration has been <c1>successfully executed</c1>');
         } else {
             $command->getIo()->writeLine('<warn>There is no migration to execute.</warn>');
         }
     } catch (\Exception $e) {
         $command->getIo()->writeLine('<error>' . $e->getMessage() . '</error>');
     }
 }
 /**
  * Test MigrationsMigrate method.
  */
 public function testMigrationsMigrate()
 {
     $this->migrationsDirectory = __DIR__ . '/../../../Fixtures/Event';
     $this->given($service = $this->createService())->and($command = new MigrationsMigrateCommand())->and($command->setIo($this->getIO()))->when($service->migrationsMigrate($command))->then()->string($this->output->fetch())->contains('Invalid migration directory');
     $this->given($service = $this->createServiceWithEmptyMigrator())->and($command = new MigrationsMigrateCommand())->and($command->setIo($this->getIO()))->when($service->migrationsMigrate($command))->then()->string($this->output->fetch())->contains('<warn>There is no migration to execute.</warn>');
     $this->migrationsDirectory = __DIR__ . '/../../../Fixtures/Migrations';
     $this->given($service = $this->createServiceWithMigrations())->and($command = new MigrationsMigrateCommand())->and($command->setIo($this->getIO()))->when($service->migrationsMigrate($command))->then()->string($this->output->fetch())->contains('Starting migration to version')->contains('The migration has been <c1>successfully executed</c1>');
 }