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 InputInterface $input
  * @param OutputInterface $output
  * @return Execs
  */
 private function createExecs(InputInterface $input, OutputInterface $output)
 {
     $execs = new Execs('mysqldump');
     $execs->setCompression($input->getOption('compression'));
     $execs->setFileName($this->getFileName($input, $output, $execs->getCompressor()));
     if (!$input->getOption('no-single-transaction')) {
         $execs->addOptions('--single-transaction --quick');
     }
     if ($input->getOption('human-readable')) {
         $execs->addOptions('--complete-insert --skip-extended-insert ');
     }
     if ($input->getOption('add-routines')) {
         $execs->addOptions('--routines ');
     }
     $database = $this->getDatabaseHelper();
     $stripTables = $this->stripTables($input, $output);
     if ($stripTables) {
         // dump structure for strip-tables
         $execs->add('--no-data ' . $database->getMysqlClientToolConnectionString() . ' ' . implode(' ', $stripTables) . $this->postDumpPipeCommands());
         // dump data for all other tables
         $ignore = '';
         foreach ($stripTables as $stripTable) {
             $ignore .= '--ignore-table=' . $this->dbSettings['dbname'] . '.' . $stripTable . ' ';
         }
         $execs->add($ignore . $database->getMysqlClientToolConnectionString() . $this->postDumpPipeCommands());
         return $execs;
     } else {
         $execs->add($database->getMysqlClientToolConnectionString() . $this->postDumpPipeCommands());
         return $execs;
     }
 }