EdgeEntityAddMemberEventTest.php in Apigee Edge 8
File
modules/apigee_edge_actions/tests/src/Kernel/Plugin/RulesEvent/EdgeEntityAddMemberEventTest.php
View source
<?php
namespace Drupal\Tests\apigee_edge_actions\Kernel\Plugin\RulesEvent;
use Drupal\rules\Context\ContextConfig;
use Drupal\Tests\apigee_edge_actions\Kernel\ApigeeEdgeActionsRulesKernelTestBase;
class EdgeEntityAddMemberEventTest extends ApigeeEdgeActionsRulesKernelTestBase {
public static $modules = [
'apigee_edge_actions',
'apigee_edge_actions_debug',
'apigee_edge',
'apigee_edge_teams',
'apigee_mock_api_client',
'dblog',
'key',
'options',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('team_member_role');
}
public function testEvent() {
$rule = $this->expressionManager
->createRule();
$rule
->addAction('apigee_edge_actions_log_message', ContextConfig::create()
->setValue('message', "Member {{ member.first_name }} was added to team {{ team.displayName }}.")
->process('message', 'rules_tokens'));
$config_entity = $this->storage
->create([
'id' => 'app_add_member_rule',
'events' => [
[
'event_name' => 'apigee_edge_actions_entity_add_member:team',
],
],
'expression' => $rule
->getConfiguration(),
]);
$config_entity
->save();
$team = $this
->createTeam();
$this
->addUserToTeam($team, $this->account);
$this
->assertLogsContains("Event apigee_edge_actions_entity_add_member:team was dispatched.");
$this
->assertLogsContains("Member {$this->account->first_name->value} was added to team {$team->getDisplayName()}.");
}
}