function MailManagerTest::setUpMailManager
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
- 10 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
- 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 \Drupal\Core\Mail\MailManager @group Mail
Namespace
Drupal\Tests\Core\MailCode
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.