Commit ca6532e8 authored by Klaus Purer's avatar Klaus Purer
Browse files

Issue #2724595 by klausi, yanniboi: Fixed config schema for send email action

parent af395366
Loading
Loading
Loading
Loading
+2 −0
Changes for config/schema/rules.action.schema.yml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ rules.action.context_values.rules_send_email:
  label: Send e-mail action context values
  mapping:
    to:
      type: sequence
      sequence:
        type: email
    subject:
      type: text
+48 −0
Changes for tests/src/Kernel/ConfigSchemaTest.php: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\rules\Kernel;

use Drupal\rules\Context\ContextConfig;

/**
 * Tests that action specfic config schema works.
 *
 * @group rules
 */
class ConfigSchemaTest extends RulesDrupalTestBase {

  /**
   * The entity storage for Rules config entities.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $storage;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->storage = $this->container->get('entity_type.manager')->getStorage('rules_component');
  }

  /**
   * Make sure the system send email config schema works on saving.
   */
  public function testMailActionContextSchema() {
    $rule = $this->expressionManager
      ->createRule();
    $rule->addAction('rules_send_email', ContextConfig::create()
      ->setValue('to', ['test@exmaple.com'])
      ->setValue('message', 'mail body')
      ->setValue('subject', 'test subject')
    );

    $config_entity = $this->storage->create([
      'id' => 'test_rule',
    ])->setExpression($rule);
    $config_entity->save();
  }

}