function FilterAPITest::testCheckMarkupFilterOrder

Same name and namespace in other branches
  1. 9 core/modules/filter/tests/src/Kernel/FilterAPITest.php \Drupal\Tests\filter\Kernel\FilterAPITest::testCheckMarkupFilterOrder()
  2. 10 core/modules/filter/tests/src/Kernel/FilterAPITest.php \Drupal\Tests\filter\Kernel\FilterAPITest::testCheckMarkupFilterOrder()
  3. 11.x 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.');
}

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