You are here

public function UiPageTest::testCancelExpressionInRule in Rules 8.3

Tests that cancelling an expression from a rule works.

File

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

Class

UiPageTest
Tests that the Rules UI pages are reachable.

Namespace

Drupal\Tests\rules\Functional

Code

public function testCancelExpressionInRule() {

  // Setup a rule with one condition.
  $this
    ->testCreateReactionRule();
  $this
    ->clickLink('Add condition');
  $this
    ->fillField('Condition', 'rules_node_is_promoted');
  $this
    ->pressButton('Continue');
  $this
    ->fillField('context_definitions[node][setting]', 'node');
  $this
    ->pressButton('Save');

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $assert
    ->pageTextContains('You have unsaved changes.');

  // Edit and cancel.
  $this
    ->pressButton('Cancel');
  $assert
    ->pageTextContains('Canceled.');

  // Make sure that we are back at the overview listing page.
  $this
    ->assertEquals(1, preg_match('#/admin/config/workflow/rules$#', $this
    ->getSession()
    ->getCurrentUrl()));
}