function FilterSecurityTest::testDisableFilterModule

Same name and namespace in other branches
  1. 9 core/modules/filter/tests/src/Functional/FilterSecurityTest.php \Drupal\Tests\filter\Functional\FilterSecurityTest::testDisableFilterModule()
  2. 8.9.x core/modules/filter/tests/src/Functional/FilterSecurityTest.php \Drupal\Tests\filter\Functional\FilterSecurityTest::testDisableFilterModule()
  3. 10 core/modules/filter/tests/src/Functional/FilterSecurityTest.php \Drupal\Tests\filter\Functional\FilterSecurityTest::testDisableFilterModule()

Tests removal of filtered content when an active filter is disabled.

Tests that filtered content is emptied when an actively used filter module is disabled.

File

core/modules/filter/tests/src/Functional/FilterSecurityTest.php, line 64

Class

FilterSecurityTest
Tests HTML filtering with missing or skipped filters or text formats.

Namespace

Drupal\Tests\filter\Functional

Code

public function testDisableFilterModule() : void {
  // Create a new node.
  $node = $this->drupalCreateNode([
    'promote' => 1,
  ]);
  $body_raw = $node->body->value;
  $format_id = $node->body->format;
  $this->drupalGet('node/' . $node->id());
  $this->assertSession()
    ->pageTextContains($body_raw);
  // Enable the filter_test_replace filter.
  $edit = [
    'filters[filter_test_replace][status]' => 1,
  ];
  $this->drupalGet('admin/config/content/formats/manage/' . $format_id);
  $this->submitForm($edit, 'Save configuration');
  // Verify that filter_test_replace filter replaced the content.
  $this->drupalGet('node/' . $node->id());
  $this->assertSession()
    ->pageTextNotContains($body_raw);
  $this->assertSession()
    ->pageTextContains('Filter: Testing filter');
  // Disable the text format entirely.
  $this->drupalGet('admin/config/content/formats/manage/' . $format_id . '/disable');
  $this->submitForm([], 'Disable');
  // Verify that the content is empty, because the text format does not exist.
  $this->drupalGet('node/' . $node->id());
  $this->assertSession()
    ->pageTextNotContains($body_raw);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.