protected function MailHandlerTest::getAnonymousMockMessage in Drupal 10
Same name and namespace in other branches
- 8 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getAnonymousMockMessage()
- 9 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.
File
- core/
modules/ contact/ tests/ src/ Unit/ MailHandlerTest.php, line 331
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));
return $message;
}