setUpMailManager example

/** * Tests the getInstance method. * * @covers ::getInstance */
  public function testGetInstance() {
    $interface = [
      'default' => 'php_mail',
      'example_testkey' => 'test_mail_collector',
    ];
    $this->setUpMailManager($interface);

    // Test that an unmatched message_id returns the default plugin instance.     $options = ['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 = ['module' => 'example', 'key' => 'testkey'];
    $instance = $this->mailManager->getInstance($options);
    $this->assertInstanceOf('Drupal\Core\Mail\Plugin\Mail\TestMailCollector', $instance);
  }

  
Home | Imprint | This part of the site doesn't use cookies.