You are here

function FilterSecurityTestCase::testDisableFilterModule in Drupal 7

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

modules/filter/filter.test, line 854
Tests for filter.module.

Class

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

Code

function testDisableFilterModule() {

  // Create a new node.
  $node = $this
    ->drupalCreateNode(array(
    'promote' => 1,
  ));
  $body_raw = $node->body[LANGUAGE_NONE][0]['value'];
  $format_id = $node->body[LANGUAGE_NONE][0]['format'];
  $this
    ->drupalGet('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
    ->drupalPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration'));

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

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

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