function XssTest::testAttribute

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::testAttribute()
  2. 10 core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::testAttribute()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::testAttribute()

Check that strings in HTML attributes are correctly processed.

@covers ::attributes @dataProvider providerTestAttributes

File

core/tests/Drupal/Tests/Component/Utility/XssTest.php, line 498

Class

XssTest
XSS Filtering tests.

Namespace

Drupal\Tests\Component\Utility

Code

public function testAttribute($value, $expected, $message, $allowed_tags = NULL) {
    $value = Xss::filter($value, $allowed_tags);
    $this->assertEquals($expected, $value, $message);
}

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