You are here

public function MailManagerTest::testGetInstance in Zircon Profile 8.0

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

Tests the getInstance method.

@covers ::getInstance

File

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

Class

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

Namespace

Drupal\Tests\Core\Mail

Code

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);
}