Exemple #1
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.session')->getAll();
     foreach ($data as $arr) {
         $entity = new Session();
         $entity->setId($arr['id']);
         $entity->setTitle($arr['title']);
         $entity->setDeleted($arr['deleted']);
         if (!empty($arr['sessionType'])) {
             $entity->setSessionType($this->getReference('sessionTypes' . $arr['sessionType']));
         }
         if (!empty($arr['course'])) {
             $entity->setCourse($this->getReference('courses' . $arr['course']));
         }
         if (!empty($arr['publishEvent'])) {
             $entity->setPublishEvent($this->getReference('publishEvents' . $arr['publishEvent']));
         }
         $related = array('topics' => 'addTopic', 'objectives' => 'addObjective');
         foreach ($related as $key => $method) {
             foreach ($arr[$key] as $id) {
                 $entity->{$method}($this->getReference($key . $id));
             }
         }
         $manager->persist($entity);
         $this->addReference('sessions' . $arr['id'], $entity);
     }
     $manager->flush();
 }
Exemple #2
0
 /**
  * @covers Ilios\CoreBundle\Entity\Session::stampUpdate
  */
 public function testStampUpdate()
 {
     $now = new \DateTime();
     $this->object->stampUpdate();
     $updatedAt = $this->object->getUpdatedAt();
     $this->assertTrue($updatedAt instanceof \DateTime);
     $diff = $now->diff($updatedAt);
     $this->assertTrue($diff->s < 2);
 }
Exemple #3
0
 /**
  * @covers \Ilios\CoreBundle\Entity\Session::setSessionDescription
  * @covers \Ilios\CoreBundle\Entity\Session::getSessionDescription
  */
 public function testSetSessionDescription()
 {
     $this->assertTrue(method_exists($this->object, 'getSessionDescription'), "Method missing");
     $this->assertTrue(method_exists($this->object, 'setSessionDescription'), "Method missing");
     $obj = m::mock('Ilios\\CoreBundle\\Entity\\SessionDescription');
     $obj->shouldReceive('setSession')->with($this->object)->once();
     $this->object->setSessionDescription($obj);
     $this->assertSame($obj, $this->object->getSessionDescription());
 }
 /**
  * @return array
  */
 public function testExecuteDeletedOfferingProvider()
 {
     $course = new Course();
     $session = new Session();
     $session->setCourse($course);
     $offeringA = new Offering();
     $offeringA->setId(1);
     $offeringA->setSession($session);
     $alertA = new Alert();
     $alertA->setTableName('offering');
     $alertA->setTableRowId($offeringA->getId());
     $session = new Session();
     $offeringB = new Offering();
     $offeringB->setId(1);
     $offeringB->setSession($session);
     $alertB = new Alert();
     $alertB->setTableName('offering');
     $alertB->setTableRowId($offeringB->getId());
     $offeringC = new Offering();
     $offeringC->setId(1);
     $alertC = new Alert();
     $alertC->setTableName('offering');
     $alertC->setTableRowId($offeringC->getId());
     return [[$alertA, $offeringA], [$alertB, $offeringB], [$alertC, $offeringC]];
 }
 /**
  * @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;
 }
Exemple #6
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.session')->getAll();
     foreach ($data as $arr) {
         $entity = new Session();
         $entity->setId($arr['id']);
         $entity->setTitle($arr['title']);
         $entity->setAttireRequired($arr['attireRequired']);
         $entity->setEquipmentRequired($arr['equipmentRequired']);
         $entity->setSupplemental($arr['supplemental']);
         $entity->setPublishedAsTbd($arr['publishedAsTbd']);
         $entity->setPublished($arr['published']);
         if (!empty($arr['sessionType'])) {
             $entity->setSessionType($this->getReference('sessionTypes' . $arr['sessionType']));
         }
         if (!empty($arr['course'])) {
             $entity->setCourse($this->getReference('courses' . $arr['course']));
         }
         $related = array('terms' => 'addTerm', 'objectives' => 'addObjective', 'meshDescriptors' => 'addMeshDescriptor');
         foreach ($related as $key => $method) {
             foreach ($arr[$key] as $id) {
                 $entity->{$method}($this->getReference($key . $id));
             }
         }
         foreach ($arr['administrators'] as $id) {
             $entity->addAdministrator($this->getReference('users' . $id));
         }
         $manager->persist($entity);
         $this->addReference('sessions' . $arr['id'], $entity);
     }
     $manager->flush();
 }
 /**
  * Gets a course with a few offerings to use in date testing
  *
  * @return Course
  */
 protected function createTestCourseWithOfferings()
 {
     $course = $this->createTestCourse();
     $course->setSchool(new School());
     $session = new Session();
     $session->setSessionType(new SessionType());
     $offering1 = new Offering();
     $offering1->setStartDate(new DateTime('8am'));
     $offering1->setEndDate(new DateTime('9am'));
     $session->addOffering($offering1);
     $offering2 = new Offering();
     $offering2->setStartDate(new DateTime('1pm tomorrow'));
     $offering2->setEndDate(new DateTime('10am next week'));
     $session->addOffering($offering2);
     $course->addSession($session);
     return $course;
 }
Exemple #8
0
 /**
  * @covers \Ilios\CoreBundle\Entity\Offering::getSchool
  */
 public function testGetSchool()
 {
     $school = new School();
     $course = new Course();
     $course->setSchool($school);
     $session = new Session();
     $session->setCourse($course);
     $offering = new Offering();
     $offering->setSession($session);
     $this->assertSame($school, $offering->getSchool());
     $course = new Course();
     $session = new Session();
     $session->setCourse($course);
     $offering = new Offering();
     $offering->setSession($session);
     $this->assertNull($offering->getSchool());
     $session = new Session();
     $offering = new Offering();
     $offering->setSession($session);
     $this->assertNull($offering->getSchool());
     $offering = new Offering();
     $this->assertNull($offering->getSchool());
 }