function MailHandlerTest::setUp

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

Overrides UnitTestCase::setUp

File

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

Class

MailHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21contact%21src%21MailHandler.php/class/MailHandler/9" title="Provides a class for handling assembly and dispatch of contact mail messages." class="local">\Drupal\contact\MailHandler</a> @group contact

Namespace

Drupal\Tests\contact\Unit

Code

protected function setUp() : void {
    parent::setUp();
    $this->mailManager = $this->createMock('\\Drupal\\Core\\Mail\\MailManagerInterface');
    $this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
    $this->logger = $this->createMock('\\Psr\\Log\\LoggerInterface');
    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->userStorage = $this->createMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
    $this->entityTypeManager
        ->expects($this->any())
        ->method('getStorage')
        ->with('user')
        ->willReturn($this->userStorage);
    $string_translation = $this->getStringTranslationStub();
    $this->contactMailHandler = new MailHandler($this->mailManager, $this->languageManager, $this->logger, $string_translation, $this->entityTypeManager);
    $language = new Language([
        'id' => 'en',
    ]);
    $this->languageManager
        ->expects($this->any())
        ->method('getDefaultLanguage')
        ->willReturn($language);
    $this->languageManager
        ->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn($language);
}

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