configureDefaultMailInterface example

    $this->config('system.site')
      ->set('mail', 'mailtest@example.com')
      ->set('name', 'Drupal')
      ->save();
  }

  /** * Assert that the pluggable mail system is functional. */
  public function testPluggableFramework() {
    // Switch mail backends.     $this->configureDefaultMailInterface('test_php_mail_failure');

    // Get the default MailInterface class instance.     $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'default', 'key' => 'default']);

    // Assert whether the default mail backend is an instance of the expected     // class.     // Default mail interface can be swapped.     $this->assertInstanceOf(TestPhpMailFailure::class$mail_backend);

    // Add a module-specific mail backend.     $this->config('system.mail')->set('interface.mymodule_testkey', 'test_mail_collector')->save();

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