function NotificationHandlerTest::testUserMailsSent
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Kernel/NotificationHandlerTest.php \Drupal\Tests\user\Kernel\NotificationHandlerTest::testUserMailsSent()
Tests that mails are sent when the appropriate notify configuration is set.
Attributes
#[DataProvider('userMailsProvider')]
Parameters
string $method: The method to call on the mail handler.
string $configKey: The config key to test.
array $emailKeys: The mail keys to test for.
File
-
core/
modules/ user/ tests/ src/ Kernel/ NotificationHandlerTest.php, line 97
Class
- NotificationHandlerTest
- Tests NotificationHandler use of user.settings.notify.*.
Namespace
Drupal\Tests\user\KernelCode
public function testUserMailsSent(string $method, string $configKey, array $emailKeys) : void {
$this->installConfig('user');
$this->config('system.site')
->set('mail', 'test@example.com')
->save();
$this->config('user.settings')
->set($configKey, TRUE)
->save();
$notificationHandler = \Drupal::service(NotificationHandler::class);
$return = $notificationHandler->{$method}($this->createUser());
$this->assertTrue($return);
foreach ($emailKeys as $key) {
$filter = [
'key' => $key,
];
$this->assertNotEmpty($this->getMails($filter), "The mail for {$key} should be sent");
}
$this->assertSameSize($emailKeys, $this->getMails());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.