MessageSubscribeEmailTestBase.php in Message Subscribe 8
File
message_subscribe_email/tests/src/Kernel/MessageSubscribeEmailTestBase.php
View source
<?php
namespace Drupal\Tests\message_subscribe_email\Kernel;
use Drupal\message\Entity\MessageTemplate;
use Drupal\Tests\message_subscribe\Kernel\MessageSubscribeTestBase;
abstract class MessageSubscribeEmailTestBase extends MessageSubscribeTestBase {
public static $modules = [
'message_subscribe_email',
];
protected $flagService;
protected $messageTemplate;
protected $nodes;
protected $users;
public function setUp() {
parent::setUp();
$this
->installConfig([
'message_subscribe_email',
]);
$this->flagService = $this->container
->get('flag');
$node_type = $this
->createContentType();
$flags = $this->flagService
->getAllFlags();
$flag = $flags['subscribe_node'];
$flag
->set('bundles', [
$node_type
->id(),
]);
$flag
->enable();
$flag
->save();
$flag = $flags['email_node'];
$flag
->set('bundles', [
$node_type
->id(),
]);
$flag
->enable();
$flag
->save();
$permissions = [
'flag subscribe_node',
'unflag subscribe_node',
'flag email_node',
'unflag email_node',
];
$this->users[1] = $this
->createUser($permissions);
$this->users[2] = $this
->createUser($permissions);
$this->users[3] = $this
->createUser($permissions);
$settings = [];
$settings['type'] = $node_type
->id();
$settings['uid'] = $this->users[1]
->id();
$this->nodes[1] = $this
->createNode($settings);
$this->nodes[2] = $this
->createNode($settings);
$this->messageTemplate = MessageTemplate::create([
'template' => 'foo',
]);
$this->messageTemplate
->save();
$this
->config('message_subscribe.settings')
->set('default_notifiers', [])
->set('notify_own_actions', TRUE)
->save();
$this->messageSubscribers = $this->container
->get('message_subscribe.subscribers');
}
}