17 public function setUp() {
20 'wgArticlePath' =>
'/wiki/$1',
21 'wgServer' =>
'//example.org',
22 'wgCanonicalServer' =>
'http://example.org',
23 'wgScriptPath' =>
'/w',
24 'wgScript' =>
'/w/index.php',
26 $this->factory = MediaWikiServices::getInstance()->getLinkRendererFactory();
29 public function testMergeAttribs() {
41 '<a href="/wiki/Special:BlankPage" class="new foobar" '
42 .
'title="Special:BlankPage (page does not exist)" bar="baz">'
43 .
'Special:BlankPage</a>',
48 public function testMakeKnownLink() {
54 '<a href="/w/index.php?title=Foobar&foo=bar" title="Foobar">Foobar</a>',
55 $linkRenderer->makeKnownLink( $target,
null, [], [
'foo' =>
'bar' ] )
60 '<a href="/wiki/Foobar?foo=bar" title="Foobar">Foobar</a>',
61 $linkRenderer->makeKnownLink( $target,
null, [], [
'foo' =>
'bar' ] )
68 '<a href="https://example.org/wiki/Foobar" title="Foobar">Foobar</a>',
73 public function testMakeBrokenLink() {
80 '<a href="/w/index.php?title=Foobar&action=edit&redlink=1" '
81 .
'class="new" title="Foobar (page does not exist)">Foobar</a>',
87 '<a href="/w/index.php?title=Foobar&action=foobar" class="new" '
88 .
'title="Foobar (page does not exist)">Foobar</a>',
89 $linkRenderer->makeBrokenLink( $target,
null, [], [
'action' =>
'foobar' ] )
94 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
95 .
'(page does not exist)">Special:Foobar</a>',
101 '<a href="/w/index.php?title=Foobar&action=edit&redlink=1" '
102 .
'class="new" title="Foobar (page does not exist)">Foobar</a>',
103 $linkRenderer->makeBrokenLink( $target->createFragmentTarget(
'foobar' ) )
107 public function testMakeLink() {
112 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
113 .
'(page does not exist)">foo</a>',
118 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">blank</a>',
123 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
124 .
'(page does not exist)"><script>evil()</script></a>',
125 $linkRenderer->makeLink( $foobar,
'<script>evil()</script>' )
129 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
130 .
'(page does not exist)"><script>evil()</script></a>',
135 '<a href="#fragment">fragment</a>',
140 public function testGetLinkClasses() {
142 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
143 $linkCache =
new LinkCache( $titleFormatter, $wanCache );
147 $linkCache->addGoodLinkObj(
153 $linkCache->addGoodLinkObj(
160 $linkCache->addGoodLinkObj(