You are here

public function UiPageTest::testMultipleContextAction in Rules 8.3

Tests that an action with a multiple context can be configured.

File

tests/src/Functional/UiPageTest.php, line 184

Class

UiPageTest
Tests that the Rules UI pages are reachable.

Namespace

Drupal\Tests\rules\Functional

Code

public function testMultipleContextAction() {
  $account = $this
    ->drupalCreateUser([
    'administer rules',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('admin/config/workflow/rules');
  $this
    ->clickLink('Add reaction rule');
  $this
    ->fillField('Label', 'Test rule');
  $this
    ->fillField('Machine-readable name', 'test_rule');
  $this
    ->fillField('React on event', 'rules_entity_insert:node');
  $this
    ->pressButton('Save');
  $this
    ->clickLink('Add action');
  $this
    ->fillField('Action', 'rules_send_email');
  $this
    ->pressButton('Continue');

  // Push the data selection switch 2 times to make sure that also works and
  // does not throw PHP notices.
  $this
    ->pressButton('Switch to data selection');
  $this
    ->pressButton('Switch to the direct input mode');
  $this
    ->fillField('context_definitions[to][setting]', 'klausi@example.com');
  $this
    ->fillField('context_definitions[subject][setting]', 'subject');
  $this
    ->fillField('context_definitions[message][setting]', 'message');
  $this
    ->pressButton('Save');

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $assert
    ->statusCodeEquals(200);
}