Exemple #1
0
 public function testNotBlankValidation()
 {
     $notBlank = array('title', 'level', 'year', 'startDate', 'endDate');
     $this->validateNotBlanks($notBlank);
     $this->object->setTitle('test');
     $this->object->setLevel(3);
     $this->object->setYear(2004);
     $this->object->setStartDate(new \DateTime());
     $this->object->setEndDate(new \DateTime());
     $this->validate(0);
 }
Exemple #2
0
 public function testNotNullValidation()
 {
     $notNull = array('school');
     $this->object->setTitle('test');
     $this->object->setLevel(3);
     $this->object->setYear(2004);
     $this->object->setStartDate(new \DateTime());
     $this->object->setEndDate(new \DateTime());
     $this->validateNotNulls($notNull);
     $this->object->setSchool(new School());
     $this->validate(0);
 }
Exemple #3
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.course')->getAll();
     foreach ($data as $arr) {
         $entity = new Course();
         $entity->setId($arr['id']);
         $entity->setTitle($arr['title']);
         $entity->setLevel($arr['level']);
         $entity->setYear($arr['year']);
         $entity->setStartDate(new \DateTime($arr['startDate']));
         $entity->setEndDate(new \DateTime($arr['endDate']));
         $entity->setDeleted($arr['deleted']);
         $entity->setExternalId($arr['externalId']);
         $entity->setLocked($arr['locked']);
         $entity->setArchived($arr['archived']);
         $entity->setOwningSchool($this->getReference('schools' . $arr['owningSchool']));
         $entity->setClerkshipType($this->getReference('courseClerkshipTypes' . $arr['clerkshipType']));
         $manager->persist($entity);
         foreach ($arr['cohorts'] as $id) {
             $entity->addCohort($this->getReference('cohorts' . $id));
         }
         foreach ($arr['directors'] as $id) {
             $entity->addDirector($this->getReference('users' . $id));
         }
         foreach ($arr['disciplines'] as $id) {
             $entity->addDiscipline($this->getReference('disciplines' . $id));
         }
         foreach ($arr['objectives'] as $id) {
             $entity->addObjective($this->getReference('objectives' . $id));
         }
         $this->addReference('courses' . $arr['id'], $entity);
     }
     $manager->flush();
 }
Exemple #4
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.course')->getAll();
     foreach ($data as $arr) {
         $entity = new Course();
         $entity->setId($arr['id']);
         $entity->setTitle($arr['title']);
         $entity->setLevel($arr['level']);
         $entity->setYear($arr['year']);
         $entity->setStartDate(new \DateTime($arr['startDate']));
         $entity->setEndDate(new \DateTime($arr['endDate']));
         $entity->setExternalId($arr['externalId']);
         $entity->setLocked($arr['locked']);
         $entity->setArchived($arr['archived']);
         $entity->setPublishedAsTbd($arr['publishedAsTbd']);
         $entity->setPublished($arr['published']);
         $entity->setSchool($this->getReference('schools' . $arr['school']));
         if (array_key_exists('ancestor', $arr)) {
             $entity->setAncestor($this->getReference('courses' . $arr['ancestor']));
         }
         if (isset($arr['clerkshipType'])) {
             $entity->setClerkshipType($this->getReference('courseClerkshipTypes' . $arr['clerkshipType']));
         }
         foreach ($arr['cohorts'] as $id) {
             $entity->addCohort($this->getReference('cohorts' . $id));
         }
         foreach ($arr['directors'] as $id) {
             $entity->addDirector($this->getReference('users' . $id));
         }
         foreach ($arr['administrators'] as $id) {
             $entity->addAdministrator($this->getReference('users' . $id));
         }
         foreach ($arr['terms'] as $id) {
             $entity->addTerm($this->getReference('terms' . $id));
         }
         foreach ($arr['objectives'] as $id) {
             $entity->addObjective($this->getReference('objectives' . $id));
         }
         foreach ($arr['meshDescriptors'] as $id) {
             $entity->addMeshDescriptor($this->getReference('meshDescriptors' . $id));
         }
         $manager->persist($entity);
         $this->addReference('courses' . $arr['id'], $entity);
     }
     $manager->flush();
 }
 /**
  * Gets a basic filled out course
  *
  * @return Course
  */
 protected function createTestCourse()
 {
     $course = new Course();
     $course->setId(10);
     $course->setTitle('test course');
     $course->setLevel(1);
     $now = new DateTime();
     $course->setYear((int) $now->format('Y'));
     $course->setStartDate(new DateTime('yesterday'));
     $course->setEndDate(new DateTime('tomorrow'));
     $course->setExternalId('I45');
     $course->setLocked(true);
     $course->setArchived(true);
     $course->setPublished(true);
     $course->setPublishedAsTbd(true);
     return $course;
 }