/**
  * @param MigrationsGenerateCommand $command
  */
 public function migrationsGenerate(MigrationsGenerateCommand $command)
 {
     $latestAvailableVersion = $this->migrator->status()->latestAvailableVersion();
     if ($latestAvailableVersion == null) {
         $latestAvailableVersion = Version::fromString('0.0.0');
     }
     $nextVersion = $latestAvailableVersion;
     if ($command->isMajor()) {
         $nextVersion->increment(VersionIncrementType::MAJOR());
     } else {
         $nextVersion->increment(VersionIncrementType::MINOR());
     }
     $command->getIo()->writeLine('Generating migrations classes for version <c2>' . $nextVersion->__toString() . '</c2>');
     try {
         $this->migrator->generate($nextVersion);
         $command->getIo()->writeLine('The migration has been <c1>successfully generated</c1>');
     } catch (\Exception $e) {
         $command->getIo()->writeLine('<error>' . $e->getMessage() . '</error>');
     }
 }
 /**
  * Test SetMajor method.
  */
 public function testSetMajor()
 {
     $this->given($command = new MigrationsGenerateCommand())->when($command->setMajor(true))->then()->boolean($command->isMajor())->isTrue();
 }
 /**
  * Test MigrationsGenerate method.
  */
 public function testMigrationsGenerate()
 {
     require_once __DIR__ . '/../../../Fixtures/BlogEventSourced.php';
     $this->given($service = $this->createService())->and($command = new MigrationsGenerateCommand(false))->and($command->setIo($this->getIO()))->and($version = Version::fromString('0.1.0'))->and($migrationFilename1 = $this->getMigratorFileName(PostEventSourced::class, $version))->and($migrationFilename2 = $this->getMigratorFileName(\BlogEventSourced::class, $version))->when($service->migrationsGenerate($command))->and($migrationClass1 = $this->getMigratorClass($migrationFilename1))->and($migrationClass2 = $this->getMigratorClass($migrationFilename2))->then()->boolean(file_exists($migrationFilename1))->isTrue()->boolean(file_exists($migrationFilename2))->isTrue()->string($migrationClass1->aggregateClassName())->isEqualTo(PostEventSourced::class)->string($migrationClass2->aggregateClassName())->isEqualTo(\BlogEventSourced::class)->string($this->output->fetch())->contains('Generating migrations classes for version')->contains('successfully generated')->and()->when($service->migrationsGenerate($command))->string($this->output->fetch())->contains('A project migration with version ' . $version->__toString() . ' already exists.');
     $this->given($service = $this->createService())->and($command = new MigrationsGenerateCommand(false))->and($command->setIo($this->getIO()))->and($version = Version::fromString('0.2.0'))->and($migrationFilename1 = $this->getMigratorFileName(PostEventSourced::class, $version))->and($migrationFilename2 = $this->getMigratorFileName(\BlogEventSourced::class, $version))->when($service->migrationsGenerate($command))->and($migrationClass1 = $this->getMigratorClass($migrationFilename1))->and($migrationClass2 = $this->getMigratorClass($migrationFilename2))->then()->boolean(file_exists($migrationFilename1))->isTrue()->boolean(file_exists($migrationFilename2))->isTrue()->string($migrationClass1->aggregateClassName())->isEqualTo(PostEventSourced::class)->string($migrationClass2->aggregateClassName())->isEqualTo(\BlogEventSourced::class)->string($this->output->fetch())->contains('Generating migrations classes for version')->contains('successfully generated');
     $this->given($service = $this->createService())->and($command = new MigrationsGenerateCommand(true))->and($command->setIo($this->getIO()))->and($version = Version::fromString('1.0.0'))->and($migrationFilename1 = $this->getMigratorFileName(PostEventSourced::class, $version))->and($migrationFilename2 = $this->getMigratorFileName(\BlogEventSourced::class, $version))->when($service->migrationsGenerate($command))->and($migrationClass1 = $this->getMigratorClass($migrationFilename1))->and($migrationClass2 = $this->getMigratorClass($migrationFilename2))->then()->boolean(file_exists($migrationFilename1))->isTrue()->boolean(file_exists($migrationFilename2))->isTrue()->string($migrationClass1->aggregateClassName())->isEqualTo(PostEventSourced::class)->string($migrationClass2->aggregateClassName())->isEqualTo(\BlogEventSourced::class);
 }