1 filter.test | FilterUnitTestCase::testImageAlignCaption() |
Tests the Image caption filter (data-caption).
File
- core/
modules/ filter/ tests/ filter.test, line 1832 - Tests for filter.module.
Class
- FilterUnitTestCase
- Unit tests for core filters.
Code
function testImageAlignCaption() {
// Set up dummy filter object.
$filter = new stdClass();
$filter->callback = '_filter_image_caption';
$input = <<<EOF
<img data-caption="Simple caption" src="foo.png" />
<img data-caption="The caption with a <a href="/foo"> link</a>.<strong> Bold tag.</strong>" src="foo.png" />
<img data-caption="The caption with a <div>not allowed tag</div>." src="foo.png" />
EOF;
$tests = array(
$input => array(
'<figure class="caption caption-img"><img src="foo.png" /><figcaption>Simple caption</figcaption></figure>' => TRUE,
'<figure class="caption caption-img"><img src="foo.png" /><figcaption>The caption with a <a href="/foo"> link</a>.<strong> Bold tag.</strong></figcaption></figure>' => TRUE,
'<figure class="caption caption-img"><img src="foo.png" /><figcaption>The caption with a not allowed tag.</figcaption></figure>' => TRUE,
'<figure class="caption caption-img"><img src="foo.png" /><figcaption>The caption with a <div>not allowed tag</div>.</figcaption></figure>' => FALSE,
// Ensure the temporarily wrapped body tag is stripped before output.
'<body>' => FALSE,
),
);
$this->assertFilteredString($filter, $tests);
}