mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9435 from unclecheese/pulls/4.5/wha-diff
BUGFIX: Ensure diff arrays are one-dimensional
This commit is contained in:
commit
39fab1974a
@ -174,6 +174,7 @@ class Diff extends \Diff
|
||||
$content = $content ? "true" : "false";
|
||||
}
|
||||
if (is_array($content)) {
|
||||
$content = array_filter($content, 'is_scalar');
|
||||
// Convert array to CSV
|
||||
$content = implode(',', $content);
|
||||
}
|
||||
|
@ -77,4 +77,14 @@ class DiffTest extends SapphireTest
|
||||
|
||||
$this->assertRegExp($expected, $actual);
|
||||
}
|
||||
|
||||
public function testDiffArray()
|
||||
{
|
||||
$from = ['Lorem', ['array here please ignore'], 'ipsum dolor'];
|
||||
$to = 'Lorem,ipsum';
|
||||
$expected = "/^Lorem,ipsum *<del>dolor<\/del> *$/";
|
||||
$actual = Diff::compareHTML($from, $to);
|
||||
|
||||
$this->assertRegExp($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user