コード例 #1
0
ファイル: WootTest.php プロジェクト: raisanen/tlon
 public function testWootMessage()
 {
     $id = new WootID(self::$SITE_ID, self::$CHAR_ID);
     $char = new WootChar($id, self::$CHAR_VALUE, self::$CHAR_VISIBLE, self::$CHAR_DEGREE);
     $msgDel = new WootMessage(WootMessage::OP_DEL, $char);
     $msgIns = new WootMessage(WootMessage::OP_INS, $char, WootChar::$CB, WootChar::$CE);
     $tmDel = WootMessage::fromDel($char);
     $tmIns = WootMessage::fromIns($char, WootChar::$CB, WootChar::$CE);
     foreach (array(array($msgDel, $tmDel), array($msgIns, $tmIns)) as $pair) {
         list($a, $b) = $pair;
         $this->assertEquals($a->op, $b->op);
         $this->assertEquals($a->char, $b->char);
         $this->assertEquals($a->prev, $b->prev);
         $this->assertEquals($a->next, $b->next);
     }
 }
コード例 #2
0
ファイル: class.wootdocument.php プロジェクト: raisanen/tlon
 /**
  * @param string  $char
  * @param int     $pos
  * @param boolean $doInsert
  * @return WootMessage
  */
 public function generateInsertMessage($char, $pos, $doInsert = true)
 {
     $next = $this->content->ithVisible($pos);
     if ($next == null) {
         $next = WootChar::$CE;
     }
     $prev = $next ? $this->content->charAt($this->content->pos($next) - 1) : WootChar::$CB;
     $newChar = $this->generateChar($char, $prev, $next);
     if ($doInsert) {
         $this->content->ins($newChar, $prev, $next);
     }
     return WootMessage::fromIns($newChar, $prev, $next);
 }