public function ConfigEntityTest::testConfigAction in Rules 8.3
Tests saving the configuration of an action and then loading it again.
File
- tests/
src/ Kernel/ ConfigEntityTest.php, line 51
Class
- ConfigEntityTest
- Tests storage and loading of Rules config entities.
Namespace
Drupal\Tests\rules\KernelCode
public function testConfigAction() {
$action = $this->expressionManager
->createAction('rules_test_debug_log');
$config_entity = $this->storage
->create([
'id' => 'test_rule',
])
->setExpression($action);
$config_entity
->save();
// The logger instance has changed, refresh it.
$this->logger = $this->container
->get('logger.channel.rules_debug');
$this->logger
->addLogger($this->debugLog);
$loaded_entity = $this->storage
->load('test_rule');
$this
->assertEquals($action
->getConfiguration(), $loaded_entity
->get('component')['expression'], 'Action configuration is the same after loading the config.');
// Create the Rules expression object from the configuration.
$expression = $loaded_entity
->getExpression();
$expression
->execute();
// Test that the action logged something.
$this
->assertRulesDebugLogEntryExists('action called');
}