From 4c04416fd5ce8fe0841822302a96d8c27262797f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 28 Jun 2015 11:37:16 +0200 Subject: [PATCH] =?UTF-8?q?add=20Scope=20to=20report's=20fixture=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataFixtures/ORM/LoadReports.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/DataFixtures/ORM/LoadReports.php b/DataFixtures/ORM/LoadReports.php index ed284051b..6b70cfacd 100644 --- a/DataFixtures/ORM/LoadReports.php +++ b/DataFixtures/ORM/LoadReports.php @@ -28,6 +28,7 @@ use Chill\ReportBundle\Entity\Report; use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Faker\Factory as FakerFactory; use Chill\CustomFieldsBundle\Entity\CustomField; +use Chill\MainBundle\DataFixtures\ORM\LoadScopes; /** * Load reports into DB @@ -78,7 +79,9 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co ->setCFGroup(rand(0,10) > 5 ? $this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_education') - ); + ) + ->setScope($this->getScopeRandom()) + ; $this->fillReport($report); $manager->persist($report); } @@ -95,12 +98,23 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co ->setPerson($charline) ->setCFGroup($this->getReference('cf_group_report_logement')) ->setDate(new \DateTime('2015-01-05')) + ->setScope($this->getReference('scope_social')) ; $this->fillReport($report); $manager->persist($report); } + /** + * + * @return \Chill\MainBundle\Entity\Scope + */ + private function getScopeRandom() + { + $ref = LoadScopes::$references[array_rand(LoadScopes::$references)]; + return $this->getReference($ref); + } + private function getPeopleRandom($percentage) { $people = $this->container->get('doctrine.orm.entity_manager')