protected function SystemEmailToUsersOfRoleTest::setUp in Rules 8.3
Overrides RulesEntityIntegrationTestBase::setUp
File
- tests/
src/ Unit/ Integration/ RulesAction/ SystemEmailToUsersOfRoleTest.php, line 50
Class
- SystemEmailToUsersOfRoleTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesAction\SystemEmailToUsersOfRole @group RulesAction
Namespace
Drupal\Tests\rules\Unit\Integration\RulesActionCode
protected function setUp() : void {
parent::setUp();
$this
->enableModule('user');
// Mock the logger.factory service, make it return the Rules logger channel,
// and register it in the container.
$this->logger = $this
->prophesize(LoggerChannelInterface::class);
$logger_factory = $this
->prophesize(LoggerChannelFactoryInterface::class);
$logger_factory
->get('rules')
->willReturn($this->logger
->reveal());
$this->container
->set('logger.factory', $logger_factory
->reveal());
$this->mailManager = $this
->prophesize(MailManagerInterface::class);
$this->container
->set('plugin.manager.mail', $this->mailManager
->reveal());
// Create an array of dummy users with the 'recipient' role.
$this->accounts = [];
for ($i = 0; $i < 3; $i++) {
$account = $this
->prophesizeEntity(UserInterface::class);
$account
->getPreferredLangcode()
->willReturn('site_default');
$account
->getEmail()
->willReturn('user' . $i . '@example.com');
$account
->addRole('recipient');
// Add the 'moderator' role to only the first account.
if ($i == 0) {
$account
->addRole('moderator');
}
$this->accounts[] = $account
->reveal();
}
// Create dummy user storage object.
$this->userStorage = $this
->prophesize(UserStorageInterface::class);
$this->entityTypeManager
->getStorage('user')
->willReturn($this->userStorage
->reveal());
$this->action = $this->actionManager
->createInstance('rules_email_to_users_of_role');
}