Skip to content
Snippets Groups Projects
Commit 3408c306 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2824410 by jhodgdon: DiffFormatter component class has leak from core class

parent b156d13b
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,16 @@ class DiffFormatter { ...@@ -36,6 +36,16 @@ class DiffFormatter {
*/ */
public $trailing_context_lines = 0; public $trailing_context_lines = 0;
/**
* The line stats.
*
* @var array
*/
protected $line_stats = array(
'counter' => array('x' => 0, 'y' => 0),
'offset' => array('x' => 0, 'y' => 0),
);
/** /**
* Format a diff. * Format a diff.
* *
......
...@@ -19,16 +19,6 @@ class DiffFormatter extends DiffFormatterBase { ...@@ -19,16 +19,6 @@ class DiffFormatter extends DiffFormatterBase {
*/ */
protected $rows = array(); protected $rows = array();
/**
* The line stats.
*
* @var array
*/
protected $line_stats = array(
'counter' => array('x' => 0, 'y' => 0),
'offset' => array('x' => 0, 'y' => 0),
);
/** /**
* Creates a DiffFormatter to render diffs in a table. * Creates a DiffFormatter to render diffs in a table.
* *
......
<?php
namespace Drupal\Tests\Component\Diff;
use Drupal\Component\Diff\Diff;
use Drupal\Component\Diff\DiffFormatter;
/**
* Test DiffFormatter classes.
*
* @coversDefaultClass \Drupal\Component\Diff\DiffFormatter
*
* @group Diff
*/
class DiffFormatterTest extends \PHPUnit_Framework_TestCase {
/**
* @return array
* - Expected formatted diff output.
* - First array of text to diff.
* - Second array of text to diff.
*/
public function provideTestDiff() {
return [
'empty' => ['', [], []],
'add' => [
"3a3\n> line2a\n",
['line1', 'line2', 'line3'],
['line1', 'line2', 'line2a', 'line3'],
],
'delete' => [
"3d3\n< line2a\n",
['line1', 'line2', 'line2a', 'line3'],
['line1', 'line2', 'line3'],
],
'change' => [
"3c3\n< line2a\n---\n> line2b\n",
['line1', 'line2', 'line2a', 'line3'],
['line1', 'line2', 'line2b', 'line3'],
],
];
}
/**
* Tests whether op classes returned by DiffEngine::diff() match expectations.
*
* @covers ::format
* @dataProvider provideTestDiff
*/
public function testDiff($expected, $from, $to) {
$diff = new Diff($from, $to);
$formatter = new DiffFormatter();
$output = $formatter->format($diff);
$this->assertEquals($expected, $output);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment