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