public function testSeekComponent()
 {
     $doc = new XmlCompactDocument();
     $doc->load(self::samplesDir() . 'custom/runtime/itemsubset.xml');
     $seeker = new AssessmentTestSeeker($doc->getDocumentComponent(), array('assessmentItemRef', 'assessmentSection'));
     $ref = $seeker->seekComponent('assessmentItemRef', 0);
     $this->assertEquals('Q01', $ref->getIdentifier());
     $ref = $seeker->seekComponent('assessmentItemRef', 3);
     $this->assertEquals('Q04', $ref->getIdentifier());
     $sec = $seeker->seekComponent('assessmentSection', 0);
     $this->assertEquals('S01', $sec->getIdentifier());
     $ref = $seeker->seekComponent('assessmentItemRef', 6);
     $this->assertEquals('Q07', $ref->getIdentifier());
     $sec = $seeker->seekComponent('assessmentSection', 2);
     $this->assertEquals('S03', $sec->getIdentifier());
     // Should not be found.
     try {
         $ref = $seeker->seekComponent('responseProcessing', 25);
         $this->assertFalse(true, "The 'responseProcessing' QTI class is not registered with the AssessmentTestSeeker object.");
     } catch (OutOfBoundsException $e) {
         $this->assertTrue(true);
     }
     try {
         $ref = $seeker->seekComponent('assessmentItemRef', 100);
         $this->assertFalse(true, "Nothing should be found for 'assessmentItemRef' at position '100'. This is out of bounds.");
     } catch (OutOfBoundsException $e) {
         $this->assertTrue(true);
     }
 }
 /**
  * Read a PendingResponse object from the current binary stream.
  * 
  * @param AssessmentTestSeeker $seeker An AssessmentTestSeeker object in order to know tree position for involved QTI Components.
  * @return PendingResponses A PendingResponses object.
  * @throws QtiBinaryStreamAccessException
  */
 public function readPendingResponses(AssessmentTestSeeker $seeker)
 {
     try {
         // Read the state.
         $state = new State();
         $varCount = $this->readTinyInt();
         for ($i = 0; $i < $varCount; $i++) {
             $responseDeclaration = $seeker->seekComponent('responseDeclaration', $this->readShort());
             $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration);
             $this->readVariableValue($responseVariable);
             $state->setVariable($responseVariable);
         }
         // Read the assessmentItemRef.
         $itemRef = $seeker->seekComponent('assessmentItemRef', $this->readShort());
         // Read the occurence number.
         $occurence = $this->readTinyInt();
         return new PendingResponses($state, $itemRef, $occurence);
     } catch (BinaryStreamAccessException $e) {
         $msg = "An error occured while reading some pending responses.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
     } catch (OutOfBoundsException $e) {
         $msg = "A QTI component was not found in the assessmentTest tree structure.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::PENDING_RESPONSES, $e);
     }
 }