Beispiel #1
0
 /**
  * {@inheritdoc}
  *
  * @param string $context
  *    A context, explaining what kind of data this is. Possible contexts:
  *    - EducaCurriculum::CURRICULUM_JSON: Representation of the curriculum
  *      structure, in JSON. This information can be found on the bsn
  *      Ontology server.
  */
 public static function createFromData($data, $context = self::CURRICULUM_JSON)
 {
     switch ($context) {
         case self::CURRICULUM_JSON:
             $data = self::parseCurriculumJson($data);
             $curriculum = new EducaCurriculum($data->curriculum);
             $curriculum->setCurriculumDictionary($data->dictionary);
             return $curriculum;
     }
     // @codeCoverageIgnoreStart
     throw new CurriculumInvalidContextException();
     // @codeCoverageIgnoreEnd
 }
 /**
  * Test treating a taxonomy path.
  */
 public function testTaxonomyPathHandling()
 {
     $json = file_get_contents(FIXTURES_DIR . '/curriculum-data/educa_curriculum.json');
     $paths = json_decode(file_get_contents(FIXTURES_DIR . '/curriculum-data/educa_taxonomy_path.json'), true);
     // Create a new curriculum element.
     $curriculum = EducaCurriculum::createFromData($json, EducaCurriculum::CURRICULUM_JSON);
     $curriculum->setTreeBasedOnTaxonPath($paths, ['discipline', 'educational level']);
     // Load the expected ASCII tree.
     $expectedAsciiTree = file_get_contents(FIXTURES_DIR . '/curriculum-data/educa_taxonomy_path.ascii');
     $this->assertEquals(trim($expectedAsciiTree), $curriculum->asciiDump(), "The ASCII representation of the curriculum tree, based on the taxonomy path, is as expected.");
 }
 /**
  * {@inheritdoc}
  */
 protected function termFactory($type, $taxonId, $name = null)
 {
     $term = parent::termFactory($type, $taxonId, $name);
     return $this->mapTerm('educa', 'classification system', $term);
 }