public function testRender() { $opcodes = m::mock('bariew\\FineDiff\\Parser\\Opcodes'); $opcodes->shouldReceive('generate')->andReturn('c12'); $parser = m::mock('bariew\\FineDiff\\Parser\\Parser'); $parser->shouldReceive('parse')->andReturn($opcodes); $html = m::mock('bariew\\FineDiff\\Render\\Html'); $html->shouldReceive('process')->with('hello', $opcodes)->once(); $diff = new Diff(null, $html, $parser); $diff->render('hello', 'hello2'); }
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); }