Add tests for headings.

This commit is contained in:
Daniel Kraus
2017-09-04 20:24:23 +02:00
parent 0f0105ee47
commit 3382336a45

View File

@ -200,6 +200,35 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
];
}
/**
* @dataProvider provideLinkContentHeadingsData
*/
public function testLinkContentHeadings( $parseHeadings, $input, $expectedOutput ) {
$config = new LinkTitles\Config();
$config->parseHeadings = $parseHeadings;
LinkTitles\Splitter::invalidate();
$source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
$linker = new LinkTitles\Linker( $config );
$result = $linker->linkContent( $source );
if ( !$result ) { $result = $input; }
$this->assertSame( $expectedOutput, $result );
}
public function provideLinkContentHeadingsData() {
return [
[
true, // parseHeadings
"With parseHeadings = true,\n== a heading with link target in it ==\n should be linked",
"With parseHeadings = true,\n== a heading with [[link target]] in it ==\n should be linked",
],
[
false, // parseHeadings
"With parseHeadings = false,\n== a heading with link target in it ==\n should not be linked",
"With parseHeadings = false,\n== a heading with link target in it ==\n should not be linked",
],
];
}
public function testLinkContentBlackList() {
$config = new LinkTitles\Config();
$config->blackList = [ 'Foo', 'Link target', 'Bar' ];