function AutoSaveTest::testActionAutoSave
Tests auto saving after an action execution.
File
-
tests/
src/ Unit/ Integration/ Engine/ AutoSaveTest.php, line 21
Class
- AutoSaveTest
- Test auto saving of variables after Rules execution.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testActionAutoSave() {
$rule = $this->rulesExpressionManager
->createRule();
// Just leverage the entity save action, which by default uses auto-saving.
$rule->addAction('rules_entity_save', ContextConfig::create()->map('entity', 'entity'));
$entity = $this->prophesizeEntity(EntityInterface::class);
$entity->save()
->shouldBeCalledTimes(1);
RulesComponent::create($rule)->addContextDefinition('entity', ContextDefinition::create('entity'))
->setContextValue('entity', $entity->reveal())
->execute();
}