1 filter.test FilterSecurityTestCase::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/filter.test, line 799
Tests for filter.module.

Class

FilterSecurityTestCase
Security tests for missing/vanished text formats or filters.

Code

function testDisableFilterModule() {
  // Create a new node.
  $node = $this->backdropCreateNode(array('promote' => 1));
  $body_raw = $node->body[LANGUAGE_NONE][0]['value'];
  $format_id = $node->body[LANGUAGE_NONE][0]['format'];
  $this->backdropGet('node/' . $node->nid);
  $this->assertText($body_raw, 'Node body found.');

  // Enable the filter_test_replace filter.
  $edit = array(
    'filters[filter_test_replace][status]' => 1,
  );
  $this->backdropPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration'));

  // Verify that filter_test_replace filter replaced the content.
  $this->backdropGet('node/' . $node->nid);
  $this->assertNoText($body_raw, 'Node body not found.');
  $this->assertText('Filter: filter_test_replace', 'Testing filter output found.');

  // Disable the text format entirely.
  $this->backdropPost('admin/config/content/formats/' . $format_id . '/disable', array(), t('Disable'));

  // Verify that the content is empty, because the text format does not exist.
  $this->backdropGet('node/' . $node->nid);
  $this->assertNoText($body_raw, 'Node body not found.');
}