Skip to content
Snippets Groups Projects
Commit ab3d42bd authored by Adam G-H's avatar Adam G-H
Browse files

A touch of clean-up

parent 542a06df
No related branches found
No related tags found
No related merge requests found
......@@ -12,12 +12,18 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
*/
function automatic_updates_test_mail_alter(array &$message): void {
if (str_starts_with($message['id'], 'automatic_updates_')) {
$langcodes = [];
foreach ($message['body'] as $line) {
$line_langcodes = [];
// Get the langcode of every translated line in the mssage, including the
// subject line.
$lines = array_merge($message['body'], [
$message['subject'],
]);
foreach ($lines as $line) {
if ($line instanceof TranslatableMarkup) {
$langcodes[] = $line->getOption('langcode');
$line_langcodes[] = $line->getOption('langcode');
}
}
$message['detected_langcodes'] = array_unique($langcodes);
$message['line_langcodes'] = array_unique($line_langcodes);
}
}
......@@ -391,7 +391,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
$langcode = $message['langcode'];
$this->assertSame($langcode, $languages[$i]);
// @see automatic_updates_test_mail_alter()
$this->assertSame([$langcode], $message['detected_langcodes']);
$this->assertSame([$langcode], $message['line_langcodes']);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment