You are here

protected function MailHandlerTest::setUp 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::setUp()

Overrides UnitTestCase::setUp

File

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

Class

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

Namespace

Drupal\Tests\contact\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->mailManager = $this
    ->getMock('\\Drupal\\Core\\Mail\\MailManagerInterface');
  $this->languageManager = $this
    ->getMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $this->logger = $this
    ->getMock('\\Psr\\Log\\LoggerInterface');
  $this->entityManager = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
  $this->userStorage = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
  $this->entityManager
    ->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->entityManager);
  $language = new Language(array(
    'id' => 'en',
  ));
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getDefaultLanguage')
    ->will($this
    ->returnValue($language));
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->returnValue($language));
}