Problem/Motivation
The /core/lib/Drupal/Core/Test/AssertMailTrait.php()
uses the result of the preg_match()
function in assertTrue()
. However preg_match()
function returns 1, 0 or FALSE.
protected function assertMailPattern($field_name, $regex, $message = '', $group = 'Other') {
$mails = $this->getMails();
$mail = end($mails);
$regex_found = preg_match("/$regex/", $mail[$field_name]);
if (!$message) {
$message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $regex]);
}
return $this->assertTrue($regex_found, $message, $group);
}
Proposed resolution
Use data type casting to boolean.