/**
  * @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());
 }
Example #2
0
 /**
  * @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));
 }
Example #3
0
 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']);
         foreach ($arr['cohorts'] as $id) {
             $entity->addCohort($this->getReference('cohorts' . $id));
         }
         $entity->setPrimarySchool($this->getReference('schools' . $arr['primarySchool']));
         if (isset($arr['primaryCohort'])) {
             $entity->setPrimaryCohort($this->getReference('cohorts' . $arr['primaryCohort']));
         }
         $manager->persist($entity);
         $this->addReference('users' . $arr['id'], $entity);
     }
     $manager->flush();
 }
 /**
  * @return array
  */
 public function testExecuteProvider()
 {
     $schoolA = new School();
     $schoolA->setId(1);
     $schoolA->setTitle('Medicine');
     $schoolA->setIliosAdministratorEmail('*****@*****.**');
     $schoolA->setChangeAlertRecipients('recipientA@som.edu,recipientB@som.edu');
     $schoolB = new School();
     $schoolB->setTitle('Dentistry');
     $schoolB->setId(2);
     $schoolA->setIliosAdministratorEmail('*****@*****.**');
     $schoolB->setChangeAlertRecipients('*****@*****.**');
     $course = new Course();
     $course->setId(1);
     $course->setTitle('Course <strong>A</strong>');
     $course->setExternalId('ILIOS123');
     $course->setSchool($schoolA);
     $sessionType = new SessionType();
     $sessionType->setId(1);
     $sessionType->setTitle('Session Type A');
     $session = new Session();
     $session->setId(1);
     $session->setCourse($course);
     $session->setSessionType($sessionType);
     $session->setTitle('<i>Session A</i>');
     $instructor1 = new User();
     $instructor1->setId(1);
     $instructor1->setFirstName("D'jango");
     $instructor1->setLastName("D'avila");
     $instructor1->setEmail('*****@*****.**');
     $instructor2 = new User();
     $instructor2->setId(2);
     $instructor2->setFirstName('Mike');
     $instructor2->setLastName('Smith');
     $instructor2->setEmail('*****@*****.**');
     $instructorGroup = new InstructorGroup();
     $instructorGroup->setId(1);
     $instructorGroup->addUser($instructor2);
     $learnerGroup = new LearnerGroup();
     $learnerGroup->setId(1);
     $learnerGroup->setTitle('Learner <em>Group</em> A');
     $learner = new User();
     $learner->setId(2);
     $learner->setFirstName('Jimmy');
     $learner->setLastName("O'Mulligan");
     $offering = new Offering();
     $offering->setId(1);
     $offering->setSession($session);
     $offering->setStartDate(new \DateTime('2015-10-01 15:15:00', new \DateTimeZone('UTC')));
     $offering->setEndDate(new \DateTime('2015-10-01 18:30:00', new \DateTimeZone('UTC')));
     $offering->setRoom('Library - Room 119');
     $offering->addInstructorGroup($instructorGroup);
     $offering->addInstructor($instructor1);
     $offering->addLearnerGroup($learnerGroup);
     $offering->addLearner($learner);
     $alert = new Alert();
     $alert->setId(1);
     $alert->setDispatched(false);
     $alert->setTableName('offering');
     $alert->setTableRowId(1);
     $alert->addRecipient($schoolA);
     $i = 0;
     foreach (['A', 'B', 'C'] as $letter) {
         $alertChangeType = new AlertChangeType();
         $alertChangeType->setId(++$i);
         $alertChangeType->setTitle("Alert Change Type {$letter}");
         $alert->addChangeType($alertChangeType);
     }
     $userA = new User();
     $userA->setId(1);
     $userA->setFirstName("K'aren");
     $userA->setLastName("D'lunchtime");
     $userB = new User();
     $userB->setId(2);
     $userB->setFirstName('Billy');
     $userB->setLastName('Brown');
     $logA = new AuditLog();
     $logA->setObjectClass('alert');
     $logA->setObjectId(1);
     $logA->setUser($userA);
     $logA->setCreatedAt(new \DateTime('2015-09-20 11:12:22', new \DateTimeZone('UTC')));
     $logB = new AuditLog();
     $logB->setObjectClass('alert');
     $logB->setObjectId(1);
     $logB->setUser($userB);
     $logB->setCreatedAt(new \DateTime('2015-09-20 15:20:15', new \DateTimeZone('UTC')));
     return [[$alert, $offering, [$logA, $logB]]];
 }
Example #5
0
 /**
  * Get the user id
  *
  * @return int
  */
 public function getUserId()
 {
     return $this->user->getUserId();
 }
 /**
  * @return OfferingInterface
  *
  * @todo This is truly in bad form. Refactor fixture loading out. [ST 2015/09/25]
  */
 protected function createOffering()
 {
     $school = new School();
     $school->setId(1);
     $school->setIliosAdministratorEmail('*****@*****.**');
     $school->setTemplatePrefix('TEST');
     $school->setTitle('Testing');
     $course = new Course();
     $course->setId(1);
     $course->setTitle('Test Course 1');
     $course->setSchool($school);
     $i = 0;
     foreach (['A', 'B', 'C'] as $letter) {
         $courseObjective = new Objective();
         $courseObjective->setId(++$i);
         $courseObjective->setTitle("Course Objective {$letter}");
         $course->addObjective($courseObjective);
     }
     $session = new Session();
     $session->setId(1);
     $session->setTitle('Test Session 1');
     $session->setCourse($course);
     $sessionType = new SessionType();
     $sessionType->setId(1);
     $sessionType->setTitle('Session Type A');
     $session->setSessionType($sessionType);
     $i = 0;
     foreach (['A', 'B', 'C'] as $letter) {
         $sessionObjective = new Objective();
         $sessionObjective->setId(++$i);
         $sessionObjective->setTitle("Session Objective {$letter}");
         $session->addObjective($sessionObjective);
     }
     $instructor1 = new User();
     $instructor1->setId(1);
     $instructor1->setFirstName('Jane');
     $instructor1->setLastName('Doe');
     $instructor1->setEmail('*****@*****.**');
     $instructor2 = new User();
     $instructor2->setId(2);
     $instructor2->setFirstName('Mike');
     $instructor2->setLastName('Smith');
     $instructor2->setEmail('*****@*****.**');
     $instructorGroup = new InstructorGroup();
     $instructorGroup->setId(1);
     $instructorGroup->addUser($instructor2);
     $learnerGroup = new LearnerGroup();
     $learnerGroup->setId(1);
     $learnerGroup->setTitle('Learner Group A');
     $learner = new User();
     $learner->setId(2);
     $learner->setFirstName('Jimmy');
     $learner->setLastName('Dumas');
     $offering = new Offering();
     $offering->setId(1);
     $offering->setStartDate(new \DateTime('2015-09-28 03:45:00', new \DateTimeZone('UTC')));
     $offering->setEndDate(new \DateTime('2015-09-28 05:45:00', new \DateTimeZone('UTC')));
     $offering->setSession($session);
     $offering->addInstructor($instructor1);
     $offering->addInstructorGroup($instructorGroup);
     $offering->addLearner($learner);
     $offering->addLearnerGroup($learnerGroup);
     $offering->setRoom('Library - Room 119');
     return $offering;
 }
 /**
  * @covers \Ilios\CoreBundle\Entity\Manager\PermissionManager::userHasReadPermissionToSchool
  */
 public function testUserHasReadPermissionToSchool()
 {
     $user = new User();
     $user->setId(10);
     $school = new School();
     $school->setId(100);
     $class = 'Ilios\\CoreBundle\\Entity\\Permission';
     $em = m::mock('Doctrine\\ORM\\EntityManager');
     $repository = m::mock('Doctrine\\ORM\\Repository')->shouldReceive('findOneBy')->with(['tableRowId' => 100, 'tableName' => 'school', 'canRead' => true, 'user' => $user], null)->andReturn(new Permission())->mock();
     $registry = m::mock('Doctrine\\Bundle\\DoctrineBundle\\Registry')->shouldReceive('getManagerForClass')->andReturn($em)->shouldReceive('getRepository')->andReturn($repository)->mock();
     $manager = new PermissionManager($registry, $class);
     $this->assertTrue($manager->userHasReadPermissionToSchool($user, $school->getId()));
     $this->assertFalse($manager->userHasReadPermissionToSchool($user, null));
 }
Example #8
0
 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->setRoot($arr['root']);
         $entity->setIcsFeedKey($arr['icsFeedKey']);
         $entity->setPhone($arr['phone']);
         $entity->setCampusId($arr['campusId']);
         $entity->setUserSyncIgnore($arr['userSyncIgnore']);
         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']));
         }
         foreach ($arr['programYears'] as $id) {
             $entity->addProgramYear($this->getReference('programYears' . $id));
         }
         foreach ($arr['directedSchools'] as $id) {
             $entity->addDirectedSchool($this->getReference('schools' . $id));
         }
         foreach ($arr['administeredSchools'] as $id) {
             $entity->addAdministeredSchool($this->getReference('schools' . $id));
         }
         foreach ($arr['directedPrograms'] as $id) {
             $entity->addDirectedProgram($this->getReference('programs' . $id));
         }
         $manager->persist($entity);
         $this->addReference('users' . $arr['id'], $entity);
     }
     $manager->flush();
 }