Skip to content

Commit

Permalink
fix config xml format and unique retry max number
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles SANQUER committed Feb 25, 2013
1 parent 54705b6 commit 40015b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/Spyrit/Datalea/Faker/Dump/Dumper.php
Expand Up @@ -96,7 +96,7 @@ public function saveConfigAsXML($dir)
{
$name = $this->config->getClassName(true).'_datalea_config';

$root = new CdataSimpleXMLElement('<?xml version=\'1.0\' encoding=\'utf-8\'?><dataleaConfig/>');
$root = new CdataSimpleXMLElement('<?xml version=\'1.0\' encoding=\'utf-8\'?><datalea/>');

$root->addAttribute('classname', $this->config->getClassName());
$root->addAttribute('locale', $this->config->getLocale());
Expand Down Expand Up @@ -384,11 +384,13 @@ public function dumpJSON($dir)
JSON;
$name = $this->config->getClassName(true);

$fakeData = $this->getFakeData();

$file = $dir.DS.$name.'.json';
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$json = json_encode($this->getFakeData(), JSON_PRETTY_PRINT);
$json = json_encode($fakeData, JSON_PRETTY_PRINT);
} else {
$json = json_encode($this->getFakeData());
$json = json_encode($fakeData);
}
file_put_contents($file, $json);

Expand Down
3 changes: 1 addition & 2 deletions src/Spyrit/Datalea/Faker/Dump/Loader.php
Expand Up @@ -69,13 +69,12 @@ public function loadXmlFakerConfig($file)
foreach ($root->columns->column as $column) {
$columnConfig = new ColumnConfig();
$columnConfig->setName($column['name']);
$columnConfig->setUnique($column['unique']);
$columnConfig->setUnique(!empty($column['unique']));
$columnConfig->setValue((string) $column->value);
$columnConfig->setConvertMethod((string) $column->convert);
$config->addColumnConfig($columnConfig);
}
}

return $config;
}
}
2 changes: 1 addition & 1 deletion src/Spyrit/Datalea/Faker/Model/ColumnConfig.php
Expand Up @@ -196,7 +196,7 @@ public function generateValues(\Faker\Generator $faker, array &$values, array $v

$column = implode('-', $columnValues);
$try++;
if ($try > 10) {
if ($try > 4) {
$inc++;
$column = is_numeric($column) ? $column+1 : $column.'_'.$inc;
}
Expand Down

0 comments on commit 40015b3

Please sign in to comment.