From 8bfb9b33c115b538a19fcc84d4d0978b723bca76 Mon Sep 17 00:00:00 2001 From: Alvaro Marcos Date: Mon, 18 Feb 2013 19:58:05 +0100 Subject: [PATCH] If $manager is not in the constructor it will not be able to $this->manager->getClassMetadata... --- src/Faker/ORM/Doctrine/Populator.php | 3 +++ 1 file changed, 3 insertions(+) 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));