3 namespace Drupal\Tests\Component\Diff;
5 use Drupal\Component\Diff\Diff;
6 use Drupal\Component\Diff\DiffFormatter;
9 * Test DiffFormatter classes.
11 * @coversDefaultClass \Drupal\Component\Diff\DiffFormatter
15 class DiffFormatterTest extends \PHPUnit_Framework_TestCase {
19 * - Expected formatted diff output.
20 * - First array of text to diff.
21 * - Second array of text to diff.
23 public function provideTestDiff() {
25 'empty' => ['', [], []],
28 ['line1', 'line2', 'line3'],
29 ['line1', 'line2', 'line2a', 'line3'],
33 ['line1', 'line2', 'line2a', 'line3'],
34 ['line1', 'line2', 'line3'],
37 "3c3\n< line2a\n---\n> line2b\n",
38 ['line1', 'line2', 'line2a', 'line3'],
39 ['line1', 'line2', 'line2b', 'line3'],
45 * Tests whether op classes returned by DiffEngine::diff() match expectations.
48 * @dataProvider provideTestDiff
50 public function testDiff($expected, $from, $to) {
51 $diff = new Diff($from, $to);
52 $formatter = new DiffFormatter();
53 $output = $formatter->format($diff);
54 $this->assertEquals($expected, $output);