function CheckMarkupDeprecationTest::testCheckMarkup

Same name and namespace in other branches
  1. main core/modules/filter/tests/src/Kernel/CheckMarkupDeprecationTest.php \Drupal\Tests\filter\Kernel\CheckMarkupDeprecationTest::testCheckMarkup()

Test deprecation of check_markup().

File

core/modules/filter/tests/src/Kernel/CheckMarkupDeprecationTest.php, line 32

Class

CheckMarkupDeprecationTest
Tests deprecation of check_markup().

Namespace

Drupal\Tests\filter\Kernel

Code

public function testCheckMarkup() : void {
  FilterFormat::create([
    'format' => 'foo',
    'name' => 'Foo',
    'filters' => [
      'filter_html' => [
        'settings' => [
          'allowed_html' => '<p>',
        ],
        'status' => TRUE,
      ],
      'filter_url' => [
        'status' => TRUE,
      ],
    ],
  ])->save();
  $this->expectUserDeprecationMessage("check_markup() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There is no direct replacement. It's recommended to always return a renderable array without flattening as markup to pass the cacheability metadata. See https://www.drupal.org/node/3588040");
  $formatted = (string) check_markup(text: '<p>Visit https://example.com', format_id: 'foo', filter_types_to_skip: [
    FilterInterface::TYPE_MARKUP_LANGUAGE,
  ]);
  // The filter_html filter was applied, and filter_url skipped.
  $this->assertSame('<p>Visit https://example.com</p>', $formatted);
}

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