function UserMailNotifyTest::testUserMailsSent

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Kernel/UserMailNotifyTest.php \Drupal\Tests\user\Kernel\UserMailNotifyTest::testUserMailsSent()
  2. 8.9.x core/modules/user/tests/src/Kernel/UserMailNotifyTest.php \Drupal\Tests\user\Kernel\UserMailNotifyTest::testUserMailsSent()
  3. 10 core/modules/user/tests/src/Kernel/UserMailNotifyTest.php \Drupal\Tests\user\Kernel\UserMailNotifyTest::testUserMailsSent()

Tests mails are sent when notify.$op is TRUE.

@dataProvider userMailsProvider

Parameters

string $op: The operation being performed on the account.

array $mail_keys: The mail keys to test for.

File

core/modules/user/tests/src/Kernel/UserMailNotifyTest.php, line 84

Class

UserMailNotifyTest
Tests <a href="/api/drupal/core%21modules%21user%21user.module/function/_user_mail_notify/11.x" title="Creates and sends a notification email following a change to a user account." class="local">_user_mail_notify</a>() use of user.settings.notify.*.

Namespace

Drupal\Tests\user\Kernel

Code

public function testUserMailsSent($op, array $mail_keys) : void {
    $this->installConfig('user');
    $this->config('system.site')
        ->set('mail', 'test@example.com')
        ->save();
    $this->config('user.settings')
        ->set('notify.' . $op, TRUE)
        ->save();
    $return = _user_mail_notify($op, $this->createUser());
    $this->assertTrue($return);
    foreach ($mail_keys as $key) {
        $filter = [
            'key' => $key,
        ];
        $this->assertNotEmpty($this->getMails($filter));
    }
    $this->assertSameSize($mail_keys, $this->getMails());
}

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