Test updated no-each logic

Added a test that trigger the DiffEngine::diag. This test when run against the
old `each` loop under PHP 7.2 triggers a deprecated warning.
 #8053
This commit is contained in:
Maxime Rainville 2018-06-01 11:16:03 +12:00
parent 4b3e76a976
commit 33b14e7ec2

View File

@ -54,6 +54,25 @@ class DiffTest extends SapphireTest
$compare = preg_replace('/[\s\t\n\r]*/', '', $compare);
$expected = preg_replace('/[\s\t\n\r]*/', '', $expected);
$this->assertEquals($compare, $expected);
$this->assertEquals($expected, $compare);
}
/**
* @see https://github.com/silverstripe/silverstripe-framework/issues/8053
*/
public function testLegacyEachStatement()
{
$sentenceOne =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
$sentenceTwo =
'Nulla porttitor, ex quis commodo pharetra, diam dui efficitur justo, eu gravida elit eros vel libero.';
$from = "$sentenceOne $sentenceTwo";
$to = "$sentenceTwo $sentenceOne";
$expected = "<del>$sentenceOne</del> $sentenceTwo <ins>$sentenceOne</ins>";
$actual = Diff::compareHTML($from, $to);
$this->assertEquals($expected, $actual);
}
}