diff --git a/src/Faker/ORM/Doctrine/EntityPopulator.php b/src/Faker/ORM/Doctrine/EntityPopulator.php index cb3a9551..e84b66dd 100644 --- a/src/Faker/ORM/Doctrine/EntityPopulator.php +++ b/src/Faker/ORM/Doctrine/EntityPopulator.php @@ -73,9 +73,10 @@ class EntityPopulator } foreach ($this->class->getAssociationNames() AS $assocName) { - if (!$this->class->isIdentifier($assocName) || !$this->class->isCollectionValuedAssociation($assocName)) { + if ($this->class->isCollectionValuedAssociation($assocName)) { continue; } + $relatedClass = $this->class->getAssociationTargetClass($assocName); $formatters[$assocName] = function($inserted) use($relatedClass) { return isset($inserted[$relatedClass]) ? $inserted[$relatedClass][mt_rand(0, count($inserted[$relatedClass]) - 1)] : null; }; } @@ -101,4 +102,4 @@ class EntityPopulator return $obj; } -} \ No newline at end of file +}