function MailManagerTest::setUpMailManager
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\MailManagerTest::setUpMailManager()
- 8.9.x 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 114
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,
'mailer_dsn' => [
'scheme' => 'null',
'host' => 'null',
'user' => NULL,
'password' => NULL,
'port' => NULL,
'options' => [],
],
],
'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);
$this->request = new Request();
$this->requestStack = $this->prophesize(RequestStack::class);
$this->requestStack
->getCurrentRequest()
->willReturn($this->request);
// @see \Drupal\Core\Plugin\Factory\ContainerFactory::createInstance()
$container = new ContainerBuilder();
$container->set('config.factory', $this->configFactory);
$container->set('request_stack', $this->requestStack
->reveal());
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.