Namespace
Drupal\Tests\rules\Unit\Integration\RulesAction
File
-
tests/src/Unit/Integration/RulesAction/SendAccountEmailTest.php
View source
<?php
namespace Drupal\Tests\rules\Unit\Integration\RulesAction {
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Tests\rules\Unit\Integration\RulesEntityIntegrationTestBase;
use Drupal\user\UserInterface;
class SendAccountEmailTest extends RulesEntityIntegrationTestBase {
protected $logger;
protected $action;
protected function setUp() : void {
parent::setUp();
$this->enableModule('user');
$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->action = $this->actionManager
->createInstance('rules_send_account_email');
}
public function testSummary() {
$this->assertEquals('Send account email', $this->action
->summary());
}
public function testActionExecution() {
$account = $this->prophesizeEntity(UserInterface::class);
$account->mail = 'klausi@example.com';
$mail_type = 'test_mail_type';
$this->action
->setContextValue('user', $account->reveal())
->setContextValue('email_type', $mail_type);
$this->action
->execute();
$notifications = _user_mail_notify();
$this->assertSame([
$mail_type => 1,
], $notifications);
}
}
}
namespace {
if (!function_exists('_user_mail_notify')) {
function _user_mail_notify($op = NULL, $account = NULL, $langcode = NULL) {
static $notifications_sent;
if (!empty($op)) {
if (!isset($notifications_sent[$op])) {
$notifications_sent[$op] = 0;
}
$notifications_sent[$op]++;
return [
'result' => $notifications_sent,
];
}
return $notifications_sent;
}
}
}
Classes
| Title |
Deprecated |
Summary |
| SendAccountEmailTest |
|
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\SendAccountEmail[[api-linebreak]]
@group RulesAction |