public function EdgeEntityAddMemberEventTest::testEvent in Apigee Edge 8
Tests add_member events for Edge entities.
Throws
\Drupal\Core\Entity\EntityStorageException
\Drupal\rules\Exception\LogicException
File
- modules/
apigee_edge_actions/ tests/ src/ Kernel/ Plugin/ RulesEvent/ EdgeEntityAddMemberEventTest.php, line 65
Class
- EdgeEntityAddMemberEventTest
- Tests Edge entity add_member event.
Namespace
Drupal\Tests\apigee_edge_actions\Kernel\Plugin\RulesEventCode
public function testEvent() {
// Create an add_member rule.
$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();
// Create a new team.
$team = $this
->createTeam();
// Add team member.
$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()}.");
}