protected function MailHandlerTest::getAuthenticatedMockMessage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 364 - Contains \Drupal\Tests\contact\Unit\MailHandlerTest.
Class
- MailHandlerTest
- @coversDefaultClass \Drupal\contact\MailHandler @group contact
Namespace
Drupal\Tests\contact\UnitCode
protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
$message = $this
->getMock('\\Drupal\\contact\\MessageInterface');
$message
->expects($this
->any())
->method('isPersonal')
->willReturn(TRUE);
$message
->expects($this
->once())
->method('copySender')
->willReturn($copy_sender);
$recipient = $this
->getMock('\\Drupal\\user\\UserInterface');
$recipient
->expects($this
->once())
->method('getEmail')
->willReturn('user2@drupal.org');
$recipient
->expects($this
->once())
->method('getUsername')
->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;
}