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); } }
/** * @param int $pos * @param boolean $doDelete * @return WootMessage */ public function generateDeleteMessage($pos, $doDelete = true) { $char = $pos instanceof WootChar ? $pos : $this->content->ithVisible($pos); if ($char != null) { if ($doDelete) { $this->content->del($char); } return WootMessage::fromDel($char); } else { return false; } }