diff --git a/src/Faker/ORM/Doctrine/Populator.php b/src/Faker/ORM/Doctrine/Populator.php index 59e50041..b1877216 100644 --- a/src/Faker/ORM/Doctrine/Populator.php +++ b/src/Faker/ORM/Doctrine/Populator.php @@ -31,6 +31,9 @@ class Populator public function addEntity($entity, $number, $customColumnFormatters = array(), $customModifiers = array(), $generateId = false) { if (!$entity instanceof \Faker\ORM\Doctrine\EntityPopulator) { + if (null === $this->manager) { + throw new \InvalidArgumentException("No entity manager passed to Doctrine Populator."); + } $entity = new \Faker\ORM\Doctrine\EntityPopulator($this->manager->getClassMetadata($entity)); } $entity->setColumnFormatters($entity->guessColumnFormatters($this->generator));