get expected fixtures for tests

- add reports non-random
- load reports into database
- add deps to faker, to fill easily reports
This commit is contained in:
2015-01-06 13:26:45 +01:00
parent 8e254849cc
commit 2d19125dcf
4 changed files with 386 additions and 7 deletions

View File

@@ -39,16 +39,42 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
public function load(ObjectManager $manager)
{
echo "loading customFieldsGroup...\n";
$report = $this->createReport($manager, array('fr' => 'Situation de logement'));
$this->addReference('cf_group_report_logement', $report);
$report = $this->createReport($manager, array('fr' => 'Alphabétisme'));
$this->addReference('cf_group_report_education', $report);
for($i=0; $i <= 3; $i++) {
echo "CFGroup Report {$i}\n";
$cFGroup = (new CustomFieldsGroup())
->setName(array('fr' => 'CFGroup Report ' . $i))
->setEntity('Chill\ReportBundle\Entity\Report');
$report = $this->createReport($manager, array('fr' => 'ZZ Rapport aléatoire '.$i));
$manager->persist($cFGroup);
$this->addReference('cf_group_report_'.$i, $cFGroup);
$this->addReference('cf_group_report_'.$i, $report);
}
$manager->flush();
}
/**
* create a report and persist in the db
*
* @param ObjectManager $manager
* @param array $name
* @return CustomFieldsGroup
*/
private function createReport(ObjectManager $manager, array $name)
{
echo $name['fr']." \n";
$cFGroup = (new CustomFieldsGroup())
->setName($name)
->setEntity('Chill\ReportBundle\Entity\Report');
$manager->persist($cFGroup);
return $cFGroup;
}
}