public function testEquality()
 {
     $p1 = new DirectedPair('A', 'B');
     $p2 = new DirectedPair('A', 'B');
     $p3 = new DirectedPair('C', 'D');
     $p4 = new Pair('A', 'B');
     $p5 = new DirectedPair('D', 'C');
     $this->assertTrue($p1->equals($p2));
     $this->assertTrue($p2->equals($p1));
     $this->assertFalse($p1->equals($p3));
     $this->assertFalse($p3->equals($p1));
     $this->assertFalse($p3->equals(1337));
     $this->assertTrue($p3->equals($p3));
     $this->assertFalse($p1->equals($p4));
     $this->assertFalse($p3->equals($p5));
     $p7 = new DirectedPair('abc', 'def');
     $p8 = new DirectedPair('def', 'abc');
     $this->assertFalse($p7->equals($p8));
     $this->assertFalse($p8->equals($p7));
 }
 /**
  * Write a DirectedPair in the current binary stream.
  * 
  * @param DirectedPair $directedPair A DirectedPair object.
  * @throws QtiBinaryStreamAccessException
  */
 public function writeDirectedPair(DirectedPair $directedPair)
 {
     try {
         $this->writeString($directedPair->getFirst());
         $this->writeString($directedPair->getSecond());
     } catch (BinaryStreamAccessException $e) {
         $msg = "An error occured while writing a directedPair.";
         throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::DIRECTEDPAIR, $e);
     }
 }
Ejemplo n.º 3
0
 /**
  * Marshall a QTI directedPair datatype into its PCI JSON Representation.
  *
  * @param \qtism\common\datatypes\DirectedPair $directedPair
  * @return array
  */
 protected function marshallDirectedPair(DirectedPair $directedPair)
 {
     return array('base' => array('directedPair' => array($directedPair->getFirst(), $directedPair->getSecond())));
 }