function testDiff() { $field = new MockTracker_FormElement_Field_Text(); $text_1 = new Tracker_Artifact_ChangesetValue_Text(111, $field, false, 'Problems during <ins> installation'); $text_2 = new Tracker_Artifact_ChangesetValue_Text(111, $field, false, 'FullTextSearch does not work on Wiki pages'); $this->assertEqual($text_1->diff($text_2), '<div class="diff">' . '<div class="block">' . '<div class="difftext">' . '<div class="original">' . '<tt class="prefix">-</tt>' . '<del>FullTextSearch does not work on Wiki pages</del> ' . '</div>' . '</div>' . '<div class="difftext">' . '<div class="final">' . '<tt class="prefix">+</tt>' . '<ins>Problems during <ins> installation</ins> ' . '</div>' . '</div>' . '</div>' . '</div>'); $this->assertEqual($text_2->diff($text_1), '<div class="diff">' . '<div class="block">' . '<div class="difftext">' . '<div class="original">' . '<tt class="prefix">-</tt>' . '<del>Problems during <ins> installation</del> ' . '</div>' . '</div>' . '<div class="difftext">' . '<div class="final">' . '<tt class="prefix">+</tt>' . '<ins>FullTextSearch does not work on Wiki pages</ins> ' . '</div>' . '</div>' . '</div>' . '</div>'); }
public function itReturnsTheRESTValue() { $field = stub('Tracker_FormElement_Field_Text')->getName()->returns('field_text'); $user = aUser()->withId(101)->build(); $changeset = new Tracker_Artifact_ChangesetValue_Text(111, $field, true, 'myxedemic enthymematic', 'html'); $representation = $changeset->getRESTValue($user, $changeset); $this->assertEqual($representation->value, 'myxedemic enthymematic'); $this->assertEqual($representation->format, 'html'); }
public function itStripHTMLWhenFormatIsHTML() { $field = aTextField()->withTracker(aTracker()->withProject(mock('Project'))->build())->build(); $text = new Tracker_Artifact_ChangesetValue_Text(111, $field, false, 'Problems with my code: <b>example</b>', Tracker_Artifact_ChangesetValue_Text::HTML_CONTENT); $this->assertEqual($text->getContentAsText(), 'Problems with my code: example'); }
/** * Get the diff between this changeset value and the one passed in param * * @param Tracker_Artifact_ChangesetValue_Text $changeset_value the changeset value to compare * @param PFUser $user The user or null * * @return string The difference between another $changeset_value, false if no differences */ public function diff($changeset_value, $format = 'html', PFUser $user = null) { $previous = explode(PHP_EOL, $changeset_value->getText()); $next = explode(PHP_EOL, $this->getText()); return $this->fetchDiff($previous, $next, $format); }