public function load(ObjectManager $manager) { $data = $this->container->get('ilioscore.dataloader.user')->getAll(); foreach ($data as $arr) { $entity = new User(); $entity->setId($arr['id']); $entity->setFirstName($arr['firstName']); $entity->setLastName($arr['lastName']); $entity->setMiddleName($arr['middleName']); $entity->setEmail($arr['email']); $entity->setEnabled($arr['enabled']); $entity->setIcsFeedKey($arr['icsFeedKey']); $entity->setPhone($arr['phone']); foreach ($arr['roles'] as $id) { $entity->addRole($this->getReference('userRoles' . $id)); } foreach ($arr['cohorts'] as $id) { $entity->addCohort($this->getReference('cohorts' . $id)); } $entity->setSchool($this->getReference('schools' . $arr['school'])); if (isset($arr['primaryCohort'])) { $entity->setPrimaryCohort($this->getReference('cohorts' . $arr['primaryCohort'])); } $manager->persist($entity); $this->addReference('users' . $arr['id'], $entity); } $manager->flush(); }
/** * @covers \Ilios\CoreBundle\Entity\LearningMaterial::getOwningSchool */ public function testGetOwningSchool() { $this->assertNull($this->object->getOwningSchool()); $school = new School(); $user = new User(); $user->setSchool($school); $lm = new LearningMaterial(); $lm->setOwningUser($user); $this->assertSame($school, $lm->getOwningSchool()); $user = new User(); $lm = new LearningMaterial(); $lm->setOwningUser($user); $this->assertNull($lm->getOwningSchool()); $lm = new LearningMaterial(); $this->assertNull($lm->getOwningSchool()); }