function MailHandlerTest::getAnonymousMockMessage
Same name in other branches
- 9 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getAnonymousMockMessage()
- 8.9.x core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getAnonymousMockMessage()
- 11.x core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getAnonymousMockMessage()
Builds a mock message from anonymous user.
Parameters
array $recipients: An array of recipient email addresses.
bool $auto_reply: TRUE if auto reply is enable.
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::getAnonymousMockMessage()
- MailHandlerTest::testSendMailMessages in core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php - Tests the sendMailMessages method.
File
-
core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php, line 270
Class
- MailHandlerTest
- @coversDefaultClass \Drupal\contact\MailHandler @group contact
Namespace
Drupal\Tests\contact\UnitCode
protected function getAnonymousMockMessage($recipients, $auto_reply, $copy_sender = FALSE) {
$message = $this->createMock('\\Drupal\\contact\\MessageInterface');
$message->expects($this->any())
->method('getSenderName')
->willReturn('Anonymous');
$message->expects($this->once())
->method('getSenderMail')
->willReturn('anonymous@drupal.org');
$message->expects($this->any())
->method('isPersonal')
->willReturn(FALSE);
$message->expects($this->once())
->method('copySender')
->willReturn($copy_sender);
$message->expects($this->any())
->method('getContactForm')
->willReturn($this->getMockContactForm($recipients, $auto_reply ? 'reply' : ''));
return $message;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.