You are here

protected function CustomFilterTest::editSubRule in Custom filter 2.0.x

Edit a existing subrule.

1 call to CustomFilterTest::editSubRule()
CustomFilterTest::testModule in tests/src/Functional/CustomFilterTest.php
Run all the tests.

File

tests/src/Functional/CustomFilterTest.php, line 192

Class

CustomFilterTest
Test the Custom Filter administration and use.

Namespace

Drupal\Tests\customfilter\Functional

Code

protected function editSubRule() {
  $edit = [];
  $edit['name'] = 'Renamed Subrule';
  $edit['description'] = 'New subrule description';
  $edit['matches'] = 1;
  $edit['pattern'] = '/Drupal/i';
  $edit['code'] = FALSE;
  $edit['replacement'] = '<font color="blue">Drupal</font>';
  $this
    ->drupalGet('admin/config/content/customfilter/filter/test_filter/rule/test_subrule/edit');
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Renamed Subrule');
  $this
    ->assertSession()
    ->addressEquals('admin/config/content/customfilter/filter/test_filter');

  // Test if there is a rule with new name.
  $this
    ->assertSession()
    ->responseContains('Renamed Subrule');

  // Test if do not exist a rule with previous name, so the rule is edited
  // and not inserted as a new one.
  $this
    ->assertSession()
    ->responseNotContains('Subrule Name');
}