You are here

public function FilterAPITest::testCheckMarkupFilterOrder in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/filter/tests/src/Kernel/FilterAPITest.php \Drupal\Tests\filter\Kernel\FilterAPITest::testCheckMarkupFilterOrder()

Tests that the filter order is respected.

File

core/modules/filter/tests/src/Kernel/FilterAPITest.php, line 34

Class

FilterAPITest
Tests the behavior of the API of the Filter module.

Namespace

Drupal\Tests\filter\Kernel

Code

public function testCheckMarkupFilterOrder() {

  // Create crazy HTML format.
  $crazy_format = FilterFormat::create([
    'format' => 'crazy',
    'name' => 'Crazy',
    'weight' => 1,
    'filters' => [
      'filter_html_escape' => [
        'weight' => 10,
        'status' => 1,
      ],
      'filter_html' => [
        'weight' => -10,
        'status' => 1,
        'settings' => [
          'allowed_html' => '<p>',
        ],
      ],
    ],
  ]);
  $crazy_format
    ->save();
  $text = "<p>Llamas are <not> awesome!</p>";
  $expected_filtered_text = "&lt;p&gt;Llamas are  awesome!&lt;/p&gt;";
  $this
    ->assertEqual(check_markup($text, 'crazy'), $expected_filtered_text, 'Filters applied in correct order.');
}