Exemplo n.º 1
0
 public function testMultipleInitialization()
 {
     $command = new InitCommand();
     $command->setConfig($this->configuration);
     $command->run($this->input, $this->output);
     $this->setExpectedException(WrongCommandException::class, 'Phoenix was already initialized, run migrate or rollback command now.');
     $command->run($this->input, $this->output);
 }
Exemplo n.º 2
0
 public function testNothingToRollbackWithInitializing()
 {
     $input = new Input();
     $output = new Output();
     $command = new InitCommand();
     $command->setConfig($this->configuration);
     $command->run($input, $output);
     $command = new RollbackCommand();
     $command->setConfig($this->configuration);
     $command->run($this->input, $this->output);
     $messages = $this->output->getMessages();
     $this->assertTrue(is_array($messages));
     $this->assertArrayHasKey(0, $messages);
     $this->assertEquals('<info>Nothing to rollback</info>' . "\n", $messages[0][1]);
     $this->assertArrayNotHasKey(OutputInterface::VERBOSITY_DEBUG, $messages);
 }
Exemplo n.º 3
0
 private function check(InputInterface $input, OutputInterface $output)
 {
     try {
         $executedMigrations = $this->manager->executedMigrations();
     } catch (DatabaseQueryExecuteException $e) {
         $executedMigrations = false;
         if (!$this instanceof InitCommand) {
             $init = new InitCommand();
             $init->setConfig($this->config->getConfiguration());
             $init->execute($input, $output);
         }
     }
     if ($executedMigrations !== false && $this instanceof InitCommand) {
         throw new WrongCommandException('Phoenix was already initialized, run migrate or rollback command now.');
     }
 }
Exemplo n.º 4
0
 public function testStatusAfterAllMigrationsExecuted()
 {
     $input = new Input();
     $output = new Output();
     $command = new InitCommand();
     $command->setConfig($this->configuration);
     $command->run($input, $output);
     $input = new Input();
     $output = new Output();
     $command = new MigrateCommand();
     $command->setConfig($this->configuration);
     $command->run($input, $output);
     $executedMigrationsCount = (count($output->getMessages(0)) - 3) / 3;
     $command = new StatusCommand();
     $command->setConfig($this->configuration);
     $command->run($this->input, $this->output);
     $messages = $this->output->getMessages();
     $this->assertTrue(is_array($messages));
     $this->assertArrayHasKey(0, $messages);
     $this->assertEquals('<comment>Executed migrations</comment>' . "\n", $messages[0][1]);
     $this->assertEquals('|<info> Class name </info>|<info> Executed at </info>|' . "\n", $messages[0][3]);
     $this->assertEquals('<comment>Migrations to execute</comment>' . "\n", $messages[0][7 + $executedMigrationsCount]);
     $this->assertEquals('<info>No migrations to execute</info>' . "\n", $messages[0][8 + $executedMigrationsCount]);
     $this->assertArrayNotHasKey(OutputInterface::VERBOSITY_DEBUG, $messages);
 }