/**
  * Tests that mails are sent in a separate render context.
  *
  * @covers ::mail
  */
 public function testMailInRenderContext()
 {
     $interface = array('default' => 'php_mail', 'example_testkey' => 'test_mail_collector');
     $this->setUpMailManager($interface);
     $this->renderer->expects($this->exactly(1))->method('executeInRenderContext')->willReturnCallback(function (RenderContext $render_context, $callback) {
         $message = $callback();
         $this->assertEquals('example', $message['module']);
     });
     $this->mailManager->mail('example', 'key', '*****@*****.**', 'en');
 }
 /**
  * Tests the getInstance method.
  *
  * @covers \Drupal\Core\Mail\MailManager::getInstance()
  */
 public function testGetInstance()
 {
     $interface = array('default' => 'php_mail', 'example_testkey' => 'test_mail_collector');
     $this->setUpMailManager($interface);
     // Test that an unmatched message_id returns the default plugin instance.
     $options = array('module' => 'foo', 'key' => 'bar');
     $instance = $this->mailManager->getInstance($options);
     $this->assertInstanceOf('Drupal\\Core\\Mail\\Plugin\\Mail\\PhpMail', $instance);
     // Test that a matching message_id returns the specified plugin instance.
     $options = array('module' => 'example', 'key' => 'testkey');
     $instance = $this->mailManager->getInstance($options);
     $this->assertInstanceOf('Drupal\\Core\\Mail\\Plugin\\Mail\\TestMailCollector', $instance);
 }