protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getApplication()->getSilex();
     $outputDir = realpath(is_dir($input->getArgument('output-dir')) ? $input->getArgument('output-dir') : '.');
     $format = $input->getOption('format');
     if (!in_array($format, array('json', 'xml'))) {
         throw new \InvalidArgumentException('The format ' . $format . ' is not allowed.');
     }
     $config = new Config();
     $config->setClassName('Entity\\User')->setFakeNumber(100)->setFormats(array_keys(DumpManager::getAvailableFormats()))->setLocale('en_US')->setSeed(17846134)->setCsvDialect(Dialect::createExcelDialect())->setVariables([new Variable('firstname', 'firstName'), new Variable('lastname', 'lastName'), new Variable('emailDomain', 'freeEmailDomain'), new Variable('birthday', 'dateTimeBetween', ['Y-m-d', '1970-01-01', '2014-01-01']), new Variable('phonehome', 'phoneNumber'), new Variable('phonework', 'phoneNumber'), new Variable('phonemobile', 'phoneNumber'), new Variable('street1', 'streetAddress'), new Variable('city1', 'city'), new Variable('postalcode1', 'postcode'), new Variable('country1', 'country'), new Variable('street2', 'streetAddress'), new Variable('city2', 'city'), new Variable('postalcode2', 'postcode'), new Variable('country2', 'country')])->setColumns([new Column('firstname', '%firstname%', 'capitalize'), new Column('lastname', '%lastname%', 'capitalize'), new Column('email', '%firstname%.%lastname%@%emailDomain%', 'lowercase'), new Column('birthday', '%birthday%'), new Column('address', null, null, [new Column('home', null, null, [new Column('street', '%street1%', 'capitalize'), new Column('city', '%city1%', 'capitalize'), new Column('postalcode', '%postalcode1%'), new Column('country', '%country1%', 'capitalize')]), new Column('work', null, null, [new Column('street', '%street2%', 'capitalize'), new Column('city', '%city2%', 'capitalize'), new Column('postalcode', '%postalcode2%'), new Column('country', '%country2%', 'capitalize')])]), new Column('phone', null, null, [new Column('home', '%phonehome%'), new Column('mobile', '%phonemobile%')])]);
     $serializer = $app['fakery.config_serializer'];
     $configFile = $serializer->dump($config, $outputDir, $format);
     $output->writeln('Example Config file dumped to <info>' . $configFile) . '</info>';
 }
 protected function compressFiles(Config $config, array $files, $outputDir, Filesystem $fs)
 {
     $this->stopwatch->start('compressing_files', 'generate_dumps');
     $this->output->writeln('Compressing files into zip ...');
     $files = parent::compressFiles($config, $files, $outputDir, $fs);
     $this->stopwatch->stop('compressing_files');
     return $files;
 }
 protected function displayFormat(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Available output file formats');
     $output->writeln('');
     foreach (DumpManager::getAvailableFormats() as $format => $label) {
         $output->writeln('<info>' . $format . '</info>');
     }
     $output->writeln('');
 }
 /**
  * @covers CSanquer\FakeryGenerator\Dump\DumpManager::getAvailableFormats
  */
 public function testGetAvailableFormats()
 {
     $this->assertEquals(['csv' => 'CSV', 'excel' => 'Excel', 'yaml' => 'YAML', 'xml' => 'XML', 'json' => 'JSON', 'sql' => 'SQL', 'php' => 'PHP', 'perl' => 'Perl', 'ruby' => 'Ruby', 'python' => 'Python'], DumpManager::getAvailableFormats());
 }
Example #5
0
 /**
  *
  * @param  string $format
  * @return Config
  */
 public function addFormat($format)
 {
     if (in_array($format, array_keys(DumpManager::getAvailableFormats())) && !in_array($format, $this->formats)) {
         $this->formats[] = $format;
     }
     return $this;
 }
 /**
  * @covers CSanquer\FakeryGenerator\Dump\DumpManager::getAvailableFormatsForValidation
  */
 public function testGetAvailableFormatsForValidation()
 {
     $this->assertEquals(['csv', 'excel', 'yaml', 'xml', 'json', 'sql', 'php', 'perl', 'ruby', 'python'], DumpManager::getAvailableFormatsForValidation());
 }