function FilterSecurityTest::testDisableFilterModule
Same name and namespace in other branches
- 9 core/modules/filter/tests/src/Functional/FilterSecurityTest.php \Drupal\Tests\filter\Functional\FilterSecurityTest::testDisableFilterModule()
- 10 core/modules/filter/tests/src/Functional/FilterSecurityTest.php \Drupal\Tests\filter\Functional\FilterSecurityTest::testDisableFilterModule()
- 11.x 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 63
Class
- FilterSecurityTest
- Tests the behavior of <a href="/api/drupal/core%21modules%21filter%21filter.module/function/check_markup/8.9.x" title="Runs all the enabled filters on a piece of text." class="local">check_markup</a>() when a filter or text format vanishes, or when <a href="/api/drupal/core%21modules%21filter%21filter.module/function/check_markup/8.9.x" title="Runs all the enabled filters on a piece of text." class="local">check_markup</a>() is called in such a way that it is instructed to skip all filters of the "FilterInterface::TYPE_HTML_RESTRICTOR" type.
Namespace
Drupal\Tests\filter\FunctionalCode
public function testDisableFilterModule() {
// 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->assertText($body_raw, 'Node body found.');
// Enable the filter_test_replace filter.
$edit = [
'filters[filter_test_replace][status]' => 1,
];
$this->drupalPostForm('admin/config/content/formats/manage/' . $format_id, $edit, t('Save configuration'));
// Verify that filter_test_replace filter replaced the content.
$this->drupalGet('node/' . $node->id());
$this->assertNoText($body_raw, 'Node body not found.');
$this->assertText('Filter: Testing filter', 'Testing filter output found.');
// Disable the text format entirely.
$this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], t('Disable'));
// Verify that the content is empty, because the text format does not exist.
$this->drupalGet('node/' . $node->id());
$this->assertNoText($body_raw, 'Node body not found.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.