function EventIntegrationTest::testSystemLoggerEvent
Test that a Logger message triggers the Rules debug logger listener.
File
-
tests/
src/ Kernel/ EventIntegrationTest.php, line 132
Class
- EventIntegrationTest
- Test for the Symfony event mapping to Rules events.
Namespace
Drupal\Tests\rules\KernelCode
public function testSystemLoggerEvent() {
$rule = $this->expressionManager
->createRule();
$rule->addCondition('rules_test_true');
$rule->addAction('rules_test_debug_log');
$config_entity = $this->storage
->create([
'id' => 'test_rule',
'events' => [
[
'event_name' => 'rules_system_logger_event',
],
],
'expression' => $rule->getConfiguration(),
]);
$config_entity->save();
// The logger instance has changed, refresh it.
$this->logger = $this->container
->get('logger.channel.rules_debug');
$this->logger
->addLogger($this->debugLog);
// Creates a logger-item, that must be dispatched as event.
$this->container
->get('logger.factory')
->get('rules_test')
->notice("This message must get logged and dispatched as rules_system_logger_event");
// Test that the action in the rule logged something.
$this->assertRulesDebugLogEntryExists('action called');
}