/** * {@inheritdoc} * * @param string $context * A context, explaining what kind of data this is. Possible contexts: * - ClassificationSystemCurriculum::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 ClassificationSystemCurriculum($data->curriculum); $curriculum->setCurriculumDictionary($data->dictionary); return $curriculum; } // @codeCoverageIgnoreStart throw new CurriculumInvalidContextException(); // @codeCoverageIgnoreEnd }
/** * Test reverse mapping taxonomy terms. */ public function testReverseMapping() { $json = file_get_contents(FIXTURES_DIR . '/curriculum-data/classification_system_curriculum.json'); // Create a new curriculum element. $curriculum = ClassificationSystemCurriculum::createFromData($json, ClassificationSystemCurriculum::CURRICULUM_JSON); $term = new EducaTerm('school_level', 'independent of levels others', [], 'LOM-CHv1.2'); $this->assertEquals('indipendent_of_levels_others', $curriculum->mapTerm('classification system', 'educa', $term)->describe()->id, "Found the correct mapped term for item 'independent of levels others'."); $term = new EducaTerm('school_level', '1st and 2nd year', [], 'LOM-CHv1.2'); $this->assertEquals('1st_and_2nd_year', $curriculum->mapTerm('classification system', 'educa', $term)->describe()->id, "Found the correct mapped term for item '1st and 2nd year'."); $term = new EducaTerm('school_level', 'visual arts', [], 'LOM-CHv1.0'); $this->assertEquals('visual arts', $curriculum->mapTerm('classification system', 'educa', $term)->describe()->id, "Found the correct mapped term for item 'visual arts'."); }