function UserMailNotifyTest::testUserMailsWithoutAccountEmail
Tests mails are not sent when the account has no email address.
@dataProvider userMailsProvider
Parameters
string $op: The operation being performed on the account.
File
-
core/
modules/ user/ tests/ src/ Kernel/ UserMailNotifyTest.php, line 122
Class
- UserMailNotifyTest
- Tests _user_mail_notify() use of user.settings.notify.*.
Namespace
Drupal\Tests\user\KernelCode
public function testUserMailsWithoutAccountEmail($op) : void {
$this->installConfig('user');
$this->config('user.settings')
->set('notify.' . $op, TRUE)
->save();
$logger = $this->createMock(LoggerInterface::class);
$logger->expects($this->once())
->method('log');
/** @var \Drupal\Core\Logger\LoggerChannelFactory $logger_factory */
$logger_factory = $this->container
->get('logger.factory');
$logger_factory->get('user')
->addLogger($logger);
$return = _user_mail_notify($op, $this->createUser([], NULL, FALSE, [
'mail' => NULL,
]));
$this->assertNull($return);
if ($op == 'register_pending_approval') {
// The register_pending_approval op will cause an email to be sent to the
// site address.
$this->assertCount(1, $this->getMails());
}
else {
$this->assertEmpty($this->getMails());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.