function NotificationsTemplatesTests::diffTexts in Notifications 6.4
Same name and namespace in other branches
- 6.2 tests/notifications_templates.test \NotificationsTemplatesTests::diffTexts()
- 6.3 tests/notifications_templates.test \NotificationsTemplatesTests::diffTexts()
- 7 tests/notifications_templates.test \NotificationsTemplatesTests::diffTexts()
1 call to NotificationsTemplatesTests::diffTexts()
File
- tests/
notifications_templates.test, line 227
Class
- NotificationsTemplatesTests
- Class for testing notifications templates and message composition.
Code
function diffTexts($text1, $text2) {
$diff = array();
foreach ($text1 as $key => $value) {
if (!isset($text2[$key])) {
$diff[] = array(
$key,
str_replace("\n", '\\n', $value),
'--',
);
}
elseif (is_array($value)) {
if ($compare = $this
->compareTexts($value, $text2[$key])) {
$diff[] = array(
$key,
array(
'data' => $compare,
'colspan' => 2,
),
);
}
}
elseif ($value != $text2[$key]) {
$diff[] = array(
$key,
str_replace("\n", '\\n', $value),
str_replace("\n", '\\n', $text2[$key]),
);
}
}
return $diff;
}