Ejemplo n.º 1
0
 /**
  * @test
  */
 public function facade()
 {
     $execs = new Execs('foo');
     $this->assertInstanceOf(Uncompressed::class, $execs->getCompressor());
     $execs->setCompression('gzip');
     $this->assertInstanceOf(AbstractCompressor::class, $execs->getCompressor());
     $this->assertNull($execs->getFileName());
     $execs->setFileName('output.sql');
     $this->assertNotNull($execs->getFileName());
     $this->assertSame('output.sql', $execs->getFileName());
     $this->assertSame('foo | gzip -c  > \'output.sql\'', $execs->getBaseCommand());
     $execs->addOptions(' --bar=box --flux ');
     $this->assertSame('foo --bar=box --flux | gzip -c  > \'output.sql\'', $execs->getBaseCommand());
     $this->assertCount(1, $execs->getCommands());
     $this->assertEquals(['foo --bar=box --flux | gzip -c  > \'output.sql\''], $execs->getCommands());
     $execs->add('--muxbux');
     $execs->add('--maxbax');
     $this->assertCount(2, $execs->getCommands());
     $this->assertEquals(['foo --bar=box --flux --muxbux | gzip -c  > \'output.sql\'', 'foo --bar=box --flux --maxbax | gzip -c  >> \'output.sql\''], $execs->getCommands());
 }
Ejemplo n.º 2
0
 /**
  * @param Execs $execs
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 private function runExecs(Execs $execs, InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('only-command') && !$input->getOption('print-only-filename')) {
         foreach ($execs->getCommands() as $command) {
             $output->writeln($command);
         }
     } else {
         if ($this->nonCommandOutput($input)) {
             $output->writeln('<comment>Start dumping database <info>' . $this->dbSettings['dbname'] . '</info> to file <info>' . $execs->getFileName() . '</info>');
         }
         $commands = $input->getOption('dry-run') ? array() : $execs->getCommands();
         foreach ($commands as $command) {
             if (!$this->runExec($command, $input, $output)) {
                 return;
             }
         }
         if (!$input->getOption('stdout') && !$input->getOption('print-only-filename')) {
             $output->writeln('<info>Finished</info>');
         }
     }
     if ($input->getOption('print-only-filename')) {
         $output->writeln($execs->getFileName());
     }
 }