function PhpMailTest::createPhpMailInstance

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::createPhpMailInstance()
  2. 11.x core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::createPhpMailInstance()

Creates a mocked PhpMail object.

The method "doMail()" gets overridden to avoid a mail() call in tests.

Return value

\Drupal\Core\Mail\Plugin\Mail\PhpMail|\PHPUnit\Framework\MockObject\MockObject A PhpMail instance.

1 call to PhpMailTest::createPhpMailInstance()
PhpMailTest::testMail in core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php
Tests sending a mail using a From address with a comma in it.

File

core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php, line 51

Class

PhpMailTest
@coversDefaultClass \Drupal\Core\Mail\Plugin\Mail\PhpMail @group Mail

Namespace

Drupal\Tests\Core\Mail\Plugin\Mail

Code

protected function createPhpMailInstance() : PhpMail {
    $mailer = $this->getMockBuilder(PhpMail::class)
        ->onlyMethods([
        'doMail',
    ])
        ->getMock();
    return $mailer;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.