protected function RngScheduledRuleTest::setUp in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/RngScheduledRuleTest.php \Drupal\Tests\rng\Kernel\RngScheduledRuleTest::setUp()
- 3.x tests/src/Kernel/RngScheduledRuleTest.php \Drupal\Tests\rng\Kernel\RngScheduledRuleTest::setUp()
Overrides RngKernelTestBase::setUp
File
- tests/
src/ Kernel/ RngScheduledRuleTest.php, line 52
Class
- RngScheduledRuleTest
- Scheduled rule entity is synced with parent rule status.
Namespace
Drupal\Tests\rng\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('rng_rule');
$this
->installEntitySchema('rng_rule_component');
$this
->installEntitySchema('rng_rule_scheduler');
$this
->installEntitySchema('courier_template_collection');
$this
->installSchema('system', [
'sequences',
]);
// Test trait needs.
$this->registrationType = $this
->createRegistrationType();
$this->eventType = $this
->createEventType('entity_test', 'entity_test');
/** @var \Drupal\Core\Action\ActionManager $action_manager */
$action_manager = $this->container
->get('plugin.manager.action');
/** @var \Drupal\Core\Condition\ConditionManager $condition_manager */
$condition_manager = $this->container
->get('plugin.manager.condition');
$event_meta = $this
->createEvent();
$this->rule = Rule::create([
'event' => [
'entity' => $event_meta
->getEvent(),
],
'trigger_id' => 'rng:custom:date',
]);
$actionPlugin = $action_manager
->createInstance('rng_courier_message');
$action = RuleComponent::create([])
->setPluginId($actionPlugin
->getPluginId())
->setConfiguration($actionPlugin
->getConfiguration())
->setType('action');
$this->rule
->addComponent($action);
$conditionPlugin = $condition_manager
->createInstance('rng_rule_scheduler');
$condition = RuleComponent::create()
->setPluginId($conditionPlugin
->getPluginId())
->setConfiguration($conditionPlugin
->getConfiguration())
->setType('condition');
$condition
->save();
// Save the ID into config.
$condition
->setConfiguration([
'rng_rule_component' => $condition
->id(),
// Date in the past.
'date' => 1234,
]);
$condition
->save();
$this->condition = $condition;
}