function DiffOpOutputBuilderTest::testDiffInfiniteLoop
Same name in other branches
- 11.x core/tests/Drupal/Tests/Component/Diff/DiffOpOutputBuilderTest.php \Drupal\Tests\Component\Diff\DiffOpOutputBuilderTest::testDiffInfiniteLoop()
Tests that two files can be successfully diffed.
@covers ::toOpsArray
File
-
core/
tests/ Drupal/ Tests/ Component/ Diff/ DiffOpOutputBuilderTest.php, line 119
Class
- DiffOpOutputBuilderTest
- @coversDefaultClass \Drupal\Component\Diff\DiffOpOutputBuilder
Namespace
Drupal\Tests\Component\DiffCode
public function testDiffInfiniteLoop() : void {
$from = explode("\n", file_get_contents(__DIR__ . '/Engine/fixtures/file1.txt'));
$to = explode("\n", file_get_contents(__DIR__ . '/Engine/fixtures/file2.txt'));
$diffOpBuilder = new DiffOpOutputBuilder();
$differ = new Differ($diffOpBuilder);
$diff = $differ->diffToArray($from, $to);
$diffOps = $diffOpBuilder->toOpsArray($diff);
$this->assertCount(4, $diffOps);
$this->assertEquals($diffOps[0], new DiffOpAdd([
' - image.style.max_325x325',
]));
$this->assertEquals($diffOps[1], new DiffOpCopy([
' - image.style.max_650x650',
]));
$this->assertEquals($diffOps[2], new DiffOpChange([
' - image.style.max_325x325',
], [
'_core:',
' default_config_hash: random_hash_string_here',
]));
$this->assertEquals($diffOps[3], new DiffOpCopy([
'fallback_image_style: max_325x325',
'',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.