3 namespace Drupal\Tests\Component\Diff\Engine;
5 use Drupal\Component\Diff\Engine\HWLDFWordAccumulator;
6 use PHPUnit\Framework\TestCase;
9 * Test HWLDFWordAccumulator.
11 * @coversDefaultClass \Drupal\Component\Diff\Engine\HWLDFWordAccumulator
15 class HWLDFWordAccumulatorTest extends TestCase {
18 * Verify that we only get back a NBSP from an empty accumulator.
22 * @see Drupal\Component\Diff\Engine\HWLDFWordAccumulator::NBSP
24 public function testGetLinesEmpty() {
25 $acc = new HWLDFWordAccumulator();
26 $this->assertEquals([' '], $acc->getLines());
31 * - Expected array of lines from getLines().
32 * - Array of strings for the $words parameter to addWords().
33 * - String tag for the $tag parameter to addWords().
35 public function provideAddWords() {
37 [['wordword2'], ['word', 'word2'], 'tag'],
38 [['word', 'word2'], ['word', "\nword2"], 'tag'],
39 [[' ', 'word2'], ['', "\nword2"], 'tag'],
45 * @dataProvider provideAddWords
47 public function testAddWords($expected, $words, $tag) {
48 $acc = new HWLDFWordAccumulator();
49 $acc->addWords($words, $tag);
50 $this->assertEquals($expected, $acc->getLines());