コード例 #1
0
ファイル: LoadUserData.php プロジェクト: Okami-/ilios
 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();
 }
コード例 #2
0
ファイル: UserTest.php プロジェクト: Okami-/ilios
 /**
  * @covers Ilios\CoreBundle\Entity\User::setPrimaryCohort
  * @covers Ilios\CoreBundle\Entity\User::getPrimaryCohort
  */
 public function testSetPrimaryCohort()
 {
     $this->assertTrue(method_exists($this->object, 'setPrimaryCohort'));
     $this->assertTrue(method_exists($this->object, 'getPrimaryCohort'));
     $obj = m::mock('Ilios\\CoreBundle\\Entity\\Cohort');
     $this->object->addCohort($obj);
     $this->object->setPrimaryCohort($obj);
     $this->assertSame($obj, $this->object->getPrimaryCohort());
     $this->assertTrue($this->object->getCohorts()->contains($obj));
 }