// Ensure the caption filter works for linked images.
$input = '<a href="http://example.com/llamas/are/awesome/but/kittens/are/cool/too"><img src="llama.jpg" data-caption="Loquacious llama!" /></a>';
$expected = '<figure role="group"><a href="http://example.com/llamas/are/awesome/but/kittens/are/cool/too"><img src="llama.jpg" /></a>' . "\n" . '<figcaption>Loquacious llama!</figcaption></figure>';
$output =
$test($input);
$this->
assertSame($expected,
$output->
getProcessedText());
$this->
assertSame($attached_library,
$output->
getAttachments());
// So far we've tested that the caption filter works correctly. But we also
// want to make sure that it works well in tandem with the "Limit allowed
// HTML tags" filter, which it is typically used with.
$html_filter =
$this->filters
['filter_html'
];
$html_filter->
setConfiguration([ 'settings' =>
[ 'allowed_html' => '<img src data-align data-caption>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
],
]);
$test_with_html_filter =
function D
$input) use ($filter,
$html_filter,
$renderer) { return $renderer->
executeInRenderContext(new RenderContext(),
function D
) use ($input,
$filter,
$html_filter) { // 1. Apply HTML filter's processing step.
$output =
$html_filter->
process($input, 'und'
);
// 2. Apply caption filter's processing step.