function RulesComponentListBuilderTest::testCancelExpressionInComponent

Tests that cancelling an expression from a component works.

File

tests/src/Functional/RulesComponentListBuilderTest.php, line 99

Class

RulesComponentListBuilderTest
Tests that the Rules Component list builder pages work.

Namespace

Drupal\Tests\rules\Functional

Code

public function testCancelExpressionInComponent() {
  // Setup a rule with one condition.
  $this->testCreateRulesComponent();
  $this->clickLink('Add condition');
  $this->fillField('Condition', 'rules_user_is_blocked');
  $this->pressButton('Continue');
  $this->fillField('context_definitions[user][setting]', '@user:current_user_context:current_user');
  $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/components$#', $this->getSession()
    ->getCurrentUrl()));
}