You are here

protected function MailHandlerTest::getAnonymousMockMessage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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::getSendMailMessages in core/modules/contact/tests/src/Unit/MailHandlerTest.php
Data provider for ::testSendMailMessages.

File

core/modules/contact/tests/src/Unit/MailHandlerTest.php, line 335
Contains \Drupal\Tests\contact\Unit\MailHandlerTest.

Class

MailHandlerTest
@coversDefaultClass \Drupal\contact\MailHandler @group contact

Namespace

Drupal\Tests\contact\Unit

Code

protected function getAnonymousMockMessage($recipients, $auto_reply, $copy_sender = FALSE) {
  $message = $this
    ->getMock('\\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;
}