/**
* Tests that mails for contact messages are correctly sent.
*/
public function testSendPersonalContactMessage() { // Ensure that the web user's email needs escaping.
$mail =
$this->webUser->
getAccountName() . '&escaped@example.com';
$this->webUser->
setEmail($mail)->
save();
$this->
drupalLogin($this->webUser
);
$this->
drupalGet('user/' .
$this->contactUser->
id() . '/contact'
);
$this->
assertSession()->
assertEscaped($mail);
$message =
$this->
submitPersonalContact($this->contactUser
);
$mails =
$this->
getMails();
$this->
assertCount(1,
$mails);
$mail =
$mails[0
];
$this->
assertEquals($this->contactUser->
getEmail(),
$mail['to'
]);
$this->
assertEquals($this->
config('system.site'
)->
get('mail'
),
$mail['from'
]);
$this->
assertEquals($this->webUser->
getEmail(),
$mail['reply-to'
]);
$this->
assertEquals('user_mail',
$mail['key'
]);
$subject = '[' .
$this->
config('system.site'
)->
get('name'
) . '] ' .
$message['subject[0][value]'
];
$this->
assertEquals($subject,
$mail['subject'
], 'Subject is in sent message.'
);
$this->
assertStringContainsString('Hello ' .
$this->contactUser->
getDisplayName(),
$mail['body'
], 'Recipient name is in sent message.'
);
$this->
assertStringContainsString($this->webUser->
getDisplayName(),
$mail['body'
], 'Sender name is in sent message.'
);