function FieldFilteredMarkupTest::providerTestCreate

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php \Drupal\Tests\Core\Field\FieldFilteredMarkupTest::providerTestCreate()
  2. 8.9.x core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php \Drupal\Tests\Core\Field\FieldFilteredMarkupTest::providerTestCreate()
  3. 10 core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php \Drupal\Tests\Core\Field\FieldFilteredMarkupTest::providerTestCreate()

Provides data for testCreate().

File

core/tests/Drupal/Tests/Core/Field/FieldFilteredMarkupTest.php, line 34

Class

FieldFilteredMarkupTest
@coversDefaultClass \Drupal\Core\Field\FieldFilteredMarkup @group Field

Namespace

Drupal\Tests\Core\Field

Code

public static function providerTestCreate() {
    $data = [];
    $data[] = [
        '',
        '',
        FALSE,
    ];
    // Certain tags are filtered.
    $data[] = [
        '<script>test string</script>',
        'test string',
        TRUE,
    ];
    // Certain tags are not filtered.
    $data[] = [
        '<em>test string</em>',
        '<em>test string</em>',
        TRUE,
    ];
    // HTML will be normalized.
    $data[] = [
        '<em>test string',
        '<em>test string</em>',
        TRUE,
    ];
    // Even safe strings will be escaped.
    $safe_string = (new Prophet())->prophesize(MarkupInterface::class);
    $safe_string->__toString()
        ->willReturn('<script>test string</script>');
    $data[] = [
        $safe_string->reveal(),
        'test string',
        TRUE,
    ];
    return $data;
}

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