public function testUnmarshallState()
 {
     $json = '
         {
             "RESPONSE1": { "base" : { "identifier" : "ChoiceA" } },
             "RESPONSE2": { "list" : { "identifier" : ["_id1", "id2", "ID3"] } },
             "RESPONSE3": { "record" : [ { "name" : "rock", "base": { "identifier" : "Paper" } } ] },
             "RESPONSE4": { "base" : null }
         }
     ';
     $unmarshaller = self::createUnmarshaller();
     $state = $unmarshaller->unmarshall($json);
     $this->assertEquals(4, count($state));
     $this->assertEquals(array('RESPONSE1', 'RESPONSE2', 'RESPONSE3', 'RESPONSE4'), array_keys($state));
     $response1 = new Identifier('ChoiceA');
     $response2 = new MultipleContainer(BaseType::IDENTIFIER, array(new Identifier('_id1'), new Identifier('id2'), new Identifier('ID3')));
     $response3 = new RecordContainer(array('rock' => new Identifier('Paper')));
     $response4 = null;
     $this->assertTrue($response1->equals($state['RESPONSE1']));
     $this->assertTrue($response2->equals($state['RESPONSE2']));
     $this->assertTrue($response3->equals($state['RESPONSE3']));
     $this->assertSame($response4, $state['RESPONSE4']);
 }
Exemple #2
0
 /**
  * Marshall a QTI identifier datatype into its PCI JSON Representation.
  *
  * @param \qtism\common\datatypes\Identifier $identifier
  * @return array
  */
 protected function marshallIdentifier(Identifier $identifier)
 {
     return array('base' => array('identifier' => $identifier->getValue()));
 }