function MailManagerTest::setUpMailManager

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
  2. 10 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
  3. 11.x 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

Class

MailManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailManager.php/class/MailManager/9" title="Provides a Mail plugin manager." class="local">\Drupal\Core\Mail\MailManager</a> @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);
}

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