function FilterKernelTest::assertFilteredString
Asserts multiple filter output expectations for multiple input strings.
@internal
Parameters
\Drupal\filter\Plugin\FilterInterface $filter: An input filter object.
array $tests: An associative array, whereas each key is an arbitrary input string and each value is again an associative array whose keys are filter output strings and whose values are Booleans indicating whether the output is expected or not. For example:
$tests = [
'Input string' => [
'<p>Input string</p>' => TRUE,
'Input string<br' => FALSE,
],
];
3 calls to FilterKernelTest::assertFilteredString()
- FilterKernelTest::testHtmlEscapeFilter in core/
modules/ filter/ tests/ src/ Kernel/ FilterKernelTest.php - Tests the HTML escaping filter.
- FilterKernelTest::testLineBreakFilter in core/
modules/ filter/ tests/ src/ Kernel/ FilterKernelTest.php - Tests the line break filter.
- FilterKernelTest::testUrlFilter in core/
modules/ filter/ tests/ src/ Kernel/ FilterKernelTest.php - Tests the URL filter.
File
-
core/
modules/ filter/ tests/ src/ Kernel/ FilterKernelTest.php, line 993
Class
- FilterKernelTest
- Tests Filter module filters individually.
Namespace
Drupal\Tests\filter\KernelCode
public function assertFilteredString(FilterInterface $filter, array $tests) : void {
foreach ($tests as $source => $tasks) {
$result = $filter->process($source, $filter)
->getProcessedText();
foreach ($tasks as $value => $is_expected) {
if ($is_expected) {
$this->assertStringContainsString($value, $result, sprintf('%s: %s found. Filtered result: %s.', var_export($source, TRUE), var_export($value, TRUE), var_export($result, TRUE)));
}
else {
$this->assertStringNotContainsString($value, $result, sprintf('%s: %s not found. Filtered result: %s.', var_export($source, TRUE), var_export($value, TRUE), var_export($result, TRUE)));
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.