function MailHandlerTest::getMockContactForm

Same name in other branches
  1. 9 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getMockContactForm()
  2. 10 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getMockContactForm()
  3. 11.x core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getMockContactForm()

Builds a mock message on given scenario.

Parameters

array $recipients: An array of recipient email addresses.

string $auto_reply: An auto-reply message to send to the message author.

Return value

\Drupal\contact\ContactFormInterface|\PHPUnit\Framework\MockObject\MockObject Mock message for testing.

2 calls to MailHandlerTest::getMockContactForm()
MailHandlerTest::getAnonymousMockMessage in core/modules/contact/tests/src/Unit/MailHandlerTest.php
Builds a mock message from anonymous user.
MailHandlerTest::getAuthenticatedMockMessage in core/modules/contact/tests/src/Unit/MailHandlerTest.php
Builds a mock message from authenticated user.

File

core/modules/contact/tests/src/Unit/MailHandlerTest.php, line 398

Class

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

Namespace

Drupal\Tests\contact\Unit

Code

protected function getMockContactForm($recipients, $auto_reply) {
    $contact_form = $this->createMock('\\Drupal\\contact\\ContactFormInterface');
    $contact_form->expects($this->once())
        ->method('getRecipients')
        ->willReturn($recipients);
    $contact_form->expects($this->once())
        ->method('getReply')
        ->willReturn($auto_reply);
    return $contact_form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.