3 namespace Drupal\Tests\Component\Diff\Engine;
5 use Drupal\Component\Diff\Engine\HWLDFWordAccumulator;
8 * Test HWLDFWordAccumulator.
10 * @coversDefaultClass \Drupal\Component\Diff\Engine\HWLDFWordAccumulator
14 class HWLDFWordAccumulatorTest extends \PHPUnit_Framework_TestCase {
17 * Verify that we only get back a NBSP from an empty accumulator.
21 * @see Drupal\Component\Diff\Engine\HWLDFWordAccumulator::NBSP
23 public function testGetLinesEmpty() {
24 $acc = new HWLDFWordAccumulator();
25 $this->assertEquals([' '], $acc->getLines());
30 * - Expected array of lines from getLines().
31 * - Array of strings for the $words parameter to addWords().
32 * - String tag for the $tag parameter to addWords().
34 public function provideAddWords() {
36 [['wordword2'], ['word', 'word2'], 'tag'],
37 [['word', 'word2'], ['word', "\nword2"], 'tag'],
38 [[' ', 'word2'], ['', "\nword2"], 'tag'],
44 * @dataProvider provideAddWords
46 public function testAddWords($expected, $words, $tag) {
47 $acc = new HWLDFWordAccumulator();
48 $acc->addWords($words, $tag);
49 $this->assertEquals($expected, $acc->getLines());