function PhpMailTest::createPhpMailInstance
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::createPhpMailInstance()
- 10 core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::createPhpMailInstance()
- 9 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 87
Class
Namespace
Drupal\Tests\Core\Mail\Plugin\MailCode
protected function createPhpMailInstance() : PhpMail {
$mailer = $this->getMockBuilder(PhpMail::class)
->onlyMethods([
'doMail',
])
->getMock();
$reflection = new \ReflectionClass($mailer);
$reflection_property = $reflection->getProperty('request');
$reflection_property->setValue($mailer, new Request());
return $mailer;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.