public function testNotBlankValidation()
 {
     $notBlank = array('name', 'level');
     $this->validateNotBlanks($notBlank);
     $this->object->setName('50 char max name test');
     $this->object->setLevel(4);
     $this->validate(0);
 }
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.curriculumInventoryAcademicLevel')->getAll();
     foreach ($data as $arr) {
         $entity = new CurriculumInventoryAcademicLevel();
         $entity->setId($arr['id']);
         $manager->persist($entity);
         $this->addReference('curriculumInventoryAcademicLevels' . $arr['id'], $entity);
     }
     $manager->flush();
 }
 /**
  * @covers \Ilios\CoreBundle\Entity\CurriculumInventoryAcademicLevel::__construct
  */
 public function testConstructor()
 {
     $this->assertEmpty($this->object->getSequenceBlocks());
 }
 /**
  * @return array
  */
 public function testCompareSequenceBlocksWithDefaultStrategyProvider()
 {
     $rhett = [];
     $level1 = new CurriculumInventoryAcademicLevel();
     $level1->setLevel(1);
     $level10 = new CurriculumInventoryAcademicLevel();
     $level10->setLevel(10);
     $blockA = new CurriculumInventorySequenceBlock();
     $blockA->setId(1);
     $blockA->setTitle("Alpha");
     $blockA->setStartDate(new \DateTime('2015-09-17'));
     $blockA->setAcademicLevel($level1);
     // same as A but with different level
     $blockB = new CurriculumInventorySequenceBlock();
     $blockB->setId(1);
     $blockB->setTitle("Alpha");
     $blockB->setStartDate(new \DateTime('2015-09-17'));
     $blockB->setAcademicLevel($level10);
     // same as A but with different start date
     $blockC = new CurriculumInventorySequenceBlock();
     $blockC->setId(1);
     $blockC->setTitle("Alpha");
     $blockC->setStartDate(new \DateTime('2019-09-17'));
     $blockC->setAcademicLevel($level1);
     // same as A but with different title
     $blockD = new CurriculumInventorySequenceBlock();
     $blockD->setId(1);
     $blockD->setTitle("Beta");
     $blockD->setStartDate(new \DateTime('2015-09-17'));
     $blockD->setAcademicLevel($level1);
     // same as A but with different id
     $blockE = new CurriculumInventorySequenceBlock();
     $blockE->setId(2);
     $blockE->setTitle("Alpha");
     $blockE->setStartDate(new \DateTime('2015-09-17'));
     $blockE->setAcademicLevel($level1);
     $rhett[] = [$blockA, $blockA, 0];
     $rhett[] = [$blockB, $blockA, 1];
     $rhett[] = [$blockA, $blockB, -1];
     $rhett[] = [$blockC, $blockA, 1];
     $rhett[] = [$blockA, $blockC, -1];
     $rhett[] = [$blockD, $blockA, 1];
     $rhett[] = [$blockA, $blockD, -1];
     $rhett[] = [$blockE, $blockA, 1];
     $rhett[] = [$blockA, $blockE, -1];
     return $rhett;
 }
 /**
  * Create a CurriculumInventoryReport and its associated Academic Levels and Sequence.
  *
  * @ApiDoc(
  *   section = "CurriculumInventoryReport",
  *   description = "Create a CurriculumInventoryReport and its associated Academic Levels and Sequence.",
  *   resource = true,
  *   input="Ilios\CoreBundle\Form\Type\CurriculumInventoryReportType",
  *   output="Ilios\CoreBundle\Classes\CurriculumInventoryReportDecorator",
  *   statusCodes={
  *     201 = "Created CurriculumInventoryReport.",
  *     400 = "Bad Request.",
  *     404 = "Not Found."
  *   }
  * )
  *
  * @Rest\View(statusCode=201, serializerEnableMaxDepthChecks=true)
  *
  * @param Request $request
  *
  * @return Response
  */
 public function postAction(Request $request)
 {
     try {
         $handler = $this->container->get('ilioscore.curriculuminventoryreport.handler');
         /* @var CurriculumInventoryReportInterface $curriculumInventoryReport */
         $curriculumInventoryReport = $handler->post($this->getPostData($request));
         $authChecker = $this->get('security.authorization_checker');
         if (!$authChecker->isGranted('create', $curriculumInventoryReport)) {
             throw $this->createAccessDeniedException('Unauthorized access!');
         }
         $manager = $this->container->get('ilioscore.curriculuminventoryreport.manager');
         $levelManager = $this->container->get('ilioscore.curriculuminventoryacademiclevel.manager');
         $sequenceManager = $this->container->get('ilioscore.curriculuminventorysequence.manager');
         $manager->update($curriculumInventoryReport, false, false);
         // create academic years and sequence while at it.
         for ($i = 1, $n = 10; $i <= $n; $i++) {
             $level = new CurriculumInventoryAcademicLevel();
             $level->setLevel($i);
             $level->setName('Year ' . $i);
             // @todo i18n 'Year'. [ST 2016/06/02]
             $curriculumInventoryReport->addAcademicLevel($level);
             $level->setReport($curriculumInventoryReport);
             $levelManager->update($level, false, false);
         }
         $sequence = new CurriculumInventorySequence();
         $curriculumInventoryReport->setSequence($sequence);
         $sequence->setReport($curriculumInventoryReport);
         $sequenceManager->update($sequence, true, false);
         // flush here.
         // generate token after the fact, since it needs to include the report id.
         $curriculumInventoryReport->generateToken();
         $manager->update($curriculumInventoryReport, true, true);
         $factory = $this->get('ilioscore.curriculum_inventory_report_decorator.factory');
         $answer['curriculumInventoryReports'] = [$factory->create($curriculumInventoryReport)];
         $view = $this->view($answer, Codes::HTTP_CREATED);
         return $this->handleView($view);
     } catch (InvalidFormException $exception) {
         return $exception->getForm();
     }
 }