public function EdgeEntityInsertEventTest::testEvent in Apigee Edge 8
Tests insert events for Edge entities.
Throws
\Drupal\Core\Entity\EntityStorageException
\Drupal\rules\Exception\LogicException
File
- modules/
apigee_edge_actions/ tests/ src/ Kernel/ Plugin/ RulesEvent/ EdgeEntityInsertEventTest.php, line 42
Class
- EdgeEntityInsertEventTest
- Tests Edge entity insert event.
Namespace
Drupal\Tests\apigee_edge_actions\Kernel\Plugin\RulesEventCode
public function testEvent() {
// Create an insert rule.
$rule = $this->expressionManager
->createRule();
$rule
->addAction('apigee_edge_actions_log_message', ContextConfig::create()
->setValue('message', "App {{ developer_app.name }} was created by {{ developer.first_name }}.")
->process('message', 'rules_tokens'));
$config_entity = $this->storage
->create([
'id' => 'app_insert_rule',
'events' => [
[
'event_name' => 'apigee_edge_actions_entity_insert:developer_app',
],
],
'expression' => $rule
->getConfiguration(),
]);
$config_entity
->save();
// Insert an entity.
$entity = $this
->createDeveloperApp();
$this
->assertLogsContains("Event apigee_edge_actions_entity_insert:developer_app was dispatched.");
$this
->assertLogsContains("App {$entity->getName()} was created by {$this->account->first_name->value}.");
}