Issue #3041816 by claudiu.cristea, Lendude: Move UserMailNotifyTest under Kernel tests namespace

merge-requests/1119/head
Alex Pott 2019-04-02 09:46:46 +01:00
parent a07965a62e
commit d88a43d47f
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
1 changed files with 39 additions and 18 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace Drupal\Tests\user\Functional;
namespace Drupal\Tests\user\Kernel;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
@ -23,14 +23,38 @@ class UserMailNotifyTest extends EntityKernelTestBase {
*/
public function userMailsProvider() {
return [
['cancel_confirm', ['cancel_confirm']],
['password_reset', ['password_reset']],
['status_activated', ['status_activated']],
['status_blocked', ['status_blocked']],
['status_canceled', ['status_canceled']],
['register_admin_created', ['register_admin_created']],
['register_no_approval_required', ['register_no_approval_required']],
['register_pending_approval', ['register_pending_approval', 'register_pending_approval_admin']],
'cancel confirm notification' => [
'cancel_confirm',
['cancel_confirm'],
],
'password reset notification' => [
'password_reset',
['password_reset'],
],
'status activated notification' => [
'status_activated',
['status_activated'],
],
'status blocked notification' => [
'status_blocked',
['status_blocked'],
],
'status canceled notification' => [
'status_canceled',
['status_canceled'],
],
'register admin created notification' => [
'register_admin_created',
['register_admin_created'],
],
'register no approval required notification' => [
'register_no_approval_required',
['register_no_approval_required'],
],
'register pending approval notification' => [
'register_pending_approval',
['register_pending_approval', 'register_pending_approval_admin'],
],
];
}
@ -47,12 +71,12 @@ class UserMailNotifyTest extends EntityKernelTestBase {
public function testUserMailsSent($op, array $mail_keys) {
$this->config('user.settings')->set('notify.' . $op, TRUE)->save();
$return = _user_mail_notify($op, $this->createUser());
$this->assertTrue($return, '_user_mail_notify() returns TRUE.');
$this->assertTrue($return);
foreach ($mail_keys as $key) {
$filter = ['key' => $key];
$this->assertNotEmpty($this->getMails($filter), "Mails with $key exists.");
$this->assertNotEmpty($this->getMails($filter));
}
$this->assertCount(count($mail_keys), $this->getMails(), 'The expected number of emails sent.');
$this->assertCount(count($mail_keys), $this->getMails());
}
/**
@ -60,17 +84,14 @@ class UserMailNotifyTest extends EntityKernelTestBase {
*
* @param string $op
* The operation being performed on the account.
* @param array $mail_keys
* The mail keys to test for. Ignored by this test because we assert that no
* mails at all are sent.
*
* @dataProvider userMailsProvider
*/
public function testUserMailsNotSent($op, array $mail_keys) {
public function testUserMailsNotSent($op) {
$this->config('user.settings')->set('notify.' . $op, FALSE)->save();
$return = _user_mail_notify($op, $this->createUser());
$this->assertFalse($return, '_user_mail_notify() returns FALSE.');
$this->assertEmpty($this->getMails(), 'No emails sent by _user_mail_notify().');
$this->assertFalse($return);
$this->assertEmpty($this->getMails());
}
}