function DevelMailLogTest::testDevelMailLogMultipleBackend

Same name in other branches
  1. 4.x tests/src/Kernel/DevelMailLogTest.php \Drupal\Tests\devel\Kernel\DevelMailLogTest::testDevelMailLogMultipleBackend()
  2. 5.x tests/src/Kernel/DevelMailLogTest.php \Drupal\Tests\devel\Kernel\DevelMailLogTest::testDevelMailLogMultipleBackend()

Tests devel_mail_log plugin with multiple mail backend.

File

tests/src/Kernel/DevelMailLogTest.php, line 63

Class

DevelMailLogTest
Tests sending mails with debug interface.

Namespace

Drupal\Tests\devel\Kernel

Code

public function testDevelMailLogMultipleBackend() {
    // Configure test_mail_collector as default mail backend.
    $this->config('system.mail')
        ->set('interface.default', 'test_mail_collector')
        ->save();
    // Configure devel_mail_log as a module-specific mail backend.
    $this->config('system.mail')
        ->set('interface.somemodule', 'devel_mail_log')
        ->save();
    // Ensures that devel_mail_log is not the default mail plugin.
    $mail_backend = $this->mailManager
        ->getInstance([
        'module' => 'default',
        'key' => 'default',
    ]);
    $this->assertInstanceOf(TestMailCollector::class, $mail_backend);
    // Ensures that devel_mail_log is used as mail backend only for the
    // specified module.
    $mail_backend = $this->mailManager
        ->getInstance([
        'module' => 'somemodule',
        'key' => 'default',
    ]);
    $this->assertInstanceOf(DevelMailLog::class, $mail_backend);
}