public function testMarshallMaximal() { $identifier = 'question1'; $href = '../../question1.xml'; $required = true; $fixed = true; $preConditions = new PreConditionCollection(); $preConditions[] = new PreCondition(new BaseValue(BaseType::BOOLEAN, true)); $preConditions[] = new PreCondition(new BaseValue(BaseType::BOOLEAN, false)); $branchRules = new BranchRuleCollection(); $branchRules[] = new BranchRule(new BaseValue(BaseType::INTEGER, 1), 'target1'); $branchRules[] = new BranchRule(new BaseValue(BaseType::INTEGER, 2), 'target2'); $itemSessionControl = new ItemSessionControl(); $timeLimits = new TimeLimits(); $timeLimits->setMaxTime(new Duration('PT50S')); // 50 seconds. $variableMappings = new VariableMappingCollection(); $variableMappings[] = new VariableMapping('var1', 'var2'); $variableMappings[] = new VariableMapping('var3', 'var4'); $weights = new WeightCollection(); $weights[] = new Weight('weight1', 1.5); $templateDefaults = new TemplateDefaultCollection(); $templateDefaults[] = new TemplateDefault('tpl1', new BaseValue(BaseType::INTEGER, 15)); $categories = new IdentifierCollection(array('cat1', 'cat2')); $component = new AssessmentItemRef($identifier, $href, $categories); $component->setRequired($required); $component->setFixed($fixed); $component->setPreConditions($preConditions); $component->setBranchRules($branchRules); $component->setItemSessionControl($itemSessionControl); $component->setTimeLimits($timeLimits); $component->setWeights($weights); $component->setVariableMappings($variableMappings); $component->setTemplateDefaults($templateDefaults); $marshaller = $this->getMarshallerFactory()->createMarshaller($component); $element = $marshaller->marshall($component); $this->assertInstanceOf('\\DOMElement', $element); $this->assertEquals('assessmentItemRef', $element->nodeName); $this->assertEquals($identifier, $element->getAttribute('identifier')); $this->assertEquals($href, $element->getAttribute('href')); $this->assertEquals(implode(" ", $categories->getArrayCopy()), $element->getAttribute('category')); $this->assertEquals('true', $element->getAttribute('required')); $this->assertEquals('true', $element->getAttribute('fixed')); $weightElts = $element->getElementsByTagName('weight'); $this->assertEquals(1, $weightElts->length); $templateDefaultElts = $element->getElementsByTagName('templateDefault'); $this->assertEquals(1, $templateDefaultElts->length); $variableMappingsElts = $element->getElementsByTagName('variableMapping'); $this->assertEquals(2, $variableMappingsElts->length); $preConditionElts = $element->getElementsByTagName('preCondition'); $this->assertEquals(2, $preConditionElts->length); $branchRuleElts = $element->getElementsByTagName('branchRule'); $this->assertEquals(2, $branchRuleElts->length); $itemSessionControlElts = $element->getElementsByTagName('itemSessionControl'); $this->assertEquals(1, $itemSessionControlElts->length); $timeLimitsElts = $element->getElementsByTagName('timeLimits'); $this->assertEquals(1, $timeLimitsElts->length); }