public function testGetOpcodes() { $parser = m::mock('cogpowered\\FineDiff\\Parser\\Parser'); $parser->shouldReceive('parse')->with('foobar', 'eggfooba')->once(); $diff = new Diff(null, null, $parser); $diff->getOpcodes('foobar', 'eggfooba'); }
/** * This will produce a color-marked-up diff output in HTML from the input strings. * * @param string $str1 String 1 * @param string $str2 String 2 * @return string Formatted output. */ public function makeDiffDisplay($str1, $str2) { if ($this->stripTags) { $str1 = strip_tags($str1); $str2 = strip_tags($str2); } $diff = new Diff(); return $diff->render($str1, $str2); }
public function diff(Twig_Environment $environment, Terms $terms, Terms $with_terms) { $view_name = $this->getTermsViewName(); $terms_content = $environment->render($view_name, array('root' => $terms->getRoot())); $with_terms_content = $environment->render($view_name, array('root' => $with_terms->getRoot())); $granularity = new Sentence(); $diff = new Diff($granularity); return html_entity_decode($diff->render($terms_content, $with_terms_content, $granularity)); }
public function testInsertParagraphGranularity() { list($from, $to, $opcodes, $html) = $this->getFile('paragraph/simple'); $diff = new Diff(new Paragraph()); $generated_opcodes = $diff->getOpcodes($from, $to); // Generate opcodes $this->assertEquals($generated_opcodes, $opcodes); // Render to text from opcodes $render = new Text(); $this->assertEquals($render->process($from, $generated_opcodes), $to); // Render to html from opcodes $render = new Html(); $this->assertEquals($render->process($from, $generated_opcodes), $html); // Render $this->assertEquals($diff->render($from, $to), $html); }