function ConfigureAndExecuteTest::createRule
Helper function to create a reaction rule.
Parameters
string $label: The label for the new rule.
string $machine_name: The internal machine-readable name.
string $event: The name of the event to react on.
string $description: Optional description for the reaction rule.
Return value
ReactionRule The rule object created.
1 call to ConfigureAndExecuteTest::createRule()
- ConfigureAndExecuteTest::testConfigureAndExecute in tests/
src/ Functional/ ConfigureAndExecuteTest.php - Tests creation of a rule and then triggering its execution.
File
-
tests/
src/ Functional/ ConfigureAndExecuteTest.php, line 93
Class
- ConfigureAndExecuteTest
- Tests that a rule can be configured and triggered when a node is edited.
Namespace
Drupal\Tests\rules\FunctionalCode
protected function createRule($label, $machine_name, $event, $description = '') {
$this->drupalGet('admin/config/workflow/rules');
$this->clickLink('Add reaction rule');
$this->fillField('Label', $label);
$this->fillField('Machine-readable name', $machine_name);
$this->fillField('React on event', $event);
$this->fillField('Description', $description);
$this->pressButton('Save');
$this->assertSession()
->pageTextContains('Reaction rule ' . $label . ' has been created');
$config_factory = $this->container
->get('config.factory');
$rule = $config_factory->get('rules.reaction.' . $machine_name);
return $rule;
}