1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-19 23:09:47 +01:00

Merge pull request #43 from cvschaefer/master

Bug: populators should ignore null value column formatters instead of checking for column names not to be null
This commit is contained in:
Francois Zaninotto 2012-06-17 12:25:37 -07:00
commit 05afe8c4f2
2 changed files with 7 additions and 7 deletions

View File

@ -91,7 +91,7 @@ class EntityPopulator
$class = $this->class->getName();
$obj = new $class;
foreach ($this->columnFormatters as $field => $format) {
if (null !== $field) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
$this->class->reflFields[$field]->setValue($obj, $value);
}

View File

@ -20,7 +20,7 @@ class EntityPopulator
{
$this->class = $class;
}
public function getClass()
{
return $this->class;
@ -40,7 +40,7 @@ class EntityPopulator
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function guessColumnFormatters(\Faker\Generator $generator)
{
$formatters = array();
@ -95,7 +95,7 @@ class EntityPopulator
}
return false;
}
public function setModifiers($modifiers)
{
$this->modifiers = $modifiers;
@ -140,7 +140,7 @@ class EntityPopulator
}
return $modifiers;
}
/**
* Insert one new record using the Entity class.
*/
@ -148,7 +148,7 @@ class EntityPopulator
{
$obj = new $this->class();
foreach ($this->getColumnFormatters() as $column => $format) {
if (null !== $column) {
if (null !== $format) {
$obj->setByName($column, is_callable($format) ? $format($insertedEntities, $obj) : $format);
}
}
@ -156,7 +156,7 @@ class EntityPopulator
$modifier($obj, $insertedEntities);
}
$obj->save($con);
return $obj->getPrimaryKey();
}