You are here

protected function MailManagerTest::setUpMailManager in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
  2. 9 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()

Sets up the mail manager for testing.

2 calls to MailManagerTest::setUpMailManager()
MailManagerTest::testGetInstance in core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
Tests the getInstance method.
MailManagerTest::testMailInRenderContext in core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
Tests that mails are sent in a separate render context.

File

core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php, line 101
Contains \Drupal\Tests\Core\Mail\MailManagerTest.

Class

MailManagerTest
@coversDefaultClass \Drupal\Core\Mail\MailManager @group Mail

Namespace

Drupal\Tests\Core\Mail

Code

protected function setUpMailManager($interface = []) {

  // Use the provided config for system.mail.interface settings.
  $this->configFactory = $this
    ->getConfigFactoryStub([
    'system.mail' => [
      'interface' => $interface,
    ],
    'system.site' => [
      'mail' => 'test@example.com',
    ],
  ]);
  $logger_factory = $this
    ->createMock('\\Drupal\\Core\\Logger\\LoggerChannelFactoryInterface');
  $string_translation = $this
    ->getStringTranslationStub();
  $this->renderer = $this
    ->createMock(RendererInterface::class);

  // Construct the manager object and override its discovery.
  $this->mailManager = new TestMailManager(new \ArrayObject(), $this->cache, $this->moduleHandler, $this->configFactory, $logger_factory, $string_translation, $this->renderer);
  $this->mailManager
    ->setDiscovery($this->discovery);

  // @see \Drupal\Core\Plugin\Factory\ContainerFactory::createInstance()
  $container = new ContainerBuilder();
  $container
    ->set('config.factory', $this->configFactory);
  \Drupal::setContainer($container);
}