From c513635dc71d3c603dd15b7913a22275fb35969e Mon Sep 17 00:00:00 2001 From: Christoph Schaefer Date: Thu, 14 Jun 2012 22:04:55 +0200 Subject: [PATCH] populators should ignore null value column formatters --- src/Faker/ORM/Doctrine/EntityPopulator.php | 2 +- src/Faker/ORM/Propel/EntityPopulator.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Faker/ORM/Doctrine/EntityPopulator.php b/src/Faker/ORM/Doctrine/EntityPopulator.php index f6083d60..cb3a9551 100644 --- a/src/Faker/ORM/Doctrine/EntityPopulator.php +++ b/src/Faker/ORM/Doctrine/EntityPopulator.php @@ -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); } diff --git a/src/Faker/ORM/Propel/EntityPopulator.php b/src/Faker/ORM/Propel/EntityPopulator.php index 8fe7f425..20df3fae 100644 --- a/src/Faker/ORM/Propel/EntityPopulator.php +++ b/src/Faker/ORM/Propel/EntityPopulator.php @@ -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(); }