protected function MailHandlerTest::getAuthenticatedMockMessage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getAuthenticatedMockMessage()
Builds a mock message from authenticated user.
Parameters
bool $copy_sender: TRUE if a copy should be sent, FALSE if not.
Return value
\Drupal\contact\MessageInterface|\PHPUnit\Framework\MockObject\MockObject Mock message for testing.
1 call to MailHandlerTest::getAuthenticatedMockMessage()
- MailHandlerTest::getSendMailMessages in core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php - Data provider for ::testSendMailMessages.
File
- core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php, line 360
Class
- MailHandlerTest
- @coversDefaultClass \Drupal\contact\MailHandler @group contact
Namespace
Drupal\Tests\contact\UnitCode
protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
$message = $this
->createMock('\\Drupal\\contact\\MessageInterface');
$message
->expects($this
->any())
->method('isPersonal')
->willReturn(TRUE);
$message
->expects($this
->once())
->method('copySender')
->willReturn($copy_sender);
$recipient = $this
->createMock('\\Drupal\\user\\UserInterface');
$recipient
->expects($this
->once())
->method('getEmail')
->willReturn('user2@drupal.org');
$recipient
->expects($this
->any())
->method('getDisplayName')
->willReturn('user2');
$recipient
->expects($this
->once())
->method('getPreferredLangcode')
->willReturn('en');
$message
->expects($this
->any())
->method('getPersonalRecipient')
->willReturn($recipient);
$message
->expects($this
->any())
->method('getContactForm')
->willReturn($this
->getMockContactForm('user2@drupal.org', FALSE));
return $message;
}