public function testMarshall()
 {
     $sectionIdentifier = 'mySection1';
     $outcomeIdentifier = 'myOutcome1';
     $includeCategory = 'cat1';
     $excludeCategory = 'cat2 cat3';
     $weightIdentifier = 'myWeight1';
     $component = new OutcomeMinimum($outcomeIdentifier, $weightIdentifier);
     $component->setSectionIdentifier($sectionIdentifier);
     $component->setIncludeCategories(new IdentifierCollection(explode(" ", $includeCategory)));
     $component->setExcludeCategories(new IdentifierCollection(explode(" ", $excludeCategory)));
     $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $this->assertInstanceOf('\\DOMElement', $element);
     $this->assertEquals('outcomeMinimum', $element->nodeName);
     $this->assertEquals($sectionIdentifier, $element->getAttribute('sectionIdentifier'));
     $this->assertEquals($outcomeIdentifier, $element->getAttribute('outcomeIdentifier'));
     $this->assertEquals($weightIdentifier, $element->getAttribute('weightIdentifier'));
     $this->assertEquals($includeCategory, $element->getAttribute('includeCategory'));
     $this->assertEquals($excludeCategory, $element->getAttribute('excludeCategory'));
 }
 protected static function getOutcomeMinimum($outcomeIdentifier, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null)
 {
     $outcomeMinimum = new OutcomeMinimum($outcomeIdentifier);
     $outcomeMinimum->setSectionIdentifier($sectionIdentifier);
     if (empty($includeCategories) === false) {
         $outcomeMinimum->setIncludeCategories($includeCategories);
     }
     if (empty($excludeCategories) === false) {
         $outcomeMinimum->setExcludeCategories($excludeCategories);
     }
     if (empty($weightIdentifier) === false) {
         $outcomeMinimum->setWeightIdentifier($weightIdentifier);
     }
     return $outcomeMinimum;
 }
Ejemplo n.º 3
0
 /**
  * Marshall a outcomeMinimum QTI element in its OutcomeMinimum object equivalent.
  *
  * @param \DOMElement A DOMElement object.
  * @return \qtism\data\QtiComponent The corresponding OutcomeMinimum object.
  */
 protected function unmarshall(DOMElement $element)
 {
     $baseComponent = parent::unmarshall($element);
     if (($outcomeIdentifier = static::getDOMElementAttributeAs($element, 'outcomeIdentifier')) !== null) {
         $object = new OutcomeMinimum($outcomeIdentifier);
         $object->setSectionIdentifier($baseComponent->getSectionIdentifier());
         $object->setIncludeCategories($baseComponent->getIncludeCategories());
         $object->setExcludeCategories($baseComponent->getExcludeCategories());
         if (($weightIdentifier = static::getDOMElementAttributeAs($element, 'weightIdentifier')) !== null) {
             $object->setWeightIdentifier($weightIdentifier);
         }
         return $object;
     } else {
         $msg = "The mandatory attribute 'outcomeIdentifier' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }