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' ] )
61 '<a href="/wiki/Foobar?foo=bar" title="Foobar">Foobar</a>',
62 $linkRenderer->makeKnownLink( $target,
null, [], [
'foo' =>
'bar' ] )
69 '<a href="https://example.org/wiki/Foobar" title="Foobar">Foobar</a>',
74 public function testMakeBrokenLink() {
81 '<a href="/w/index.php?title=Foobar&action=edit&redlink=1" '
82 .
'class="new" title="Foobar (page does not exist)">Foobar</a>',
88 '<a href="/w/index.php?title=Foobar&action=foobar" class="new" '
89 .
'title="Foobar (page does not exist)">Foobar</a>',
90 $linkRenderer->makeBrokenLink( $target,
null, [], [
'action' =>
'foobar' ] )
95 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
96 .
'(page does not exist)">Special:Foobar</a>',
102 '<a href="/w/index.php?title=Foobar&action=edit&redlink=1" '
103 .
'class="new" title="Foobar (page does not exist)">Foobar</a>',
104 $linkRenderer->makeBrokenLink( $target->createFragmentTarget(
'foobar' ) )
108 public function testMakeLink() {
113 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
114 .
'(page does not exist)">foo</a>',
119 '<a href="/wiki/Special:BlankPage" title="Special:BlankPage">blank</a>',
124 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
125 .
'(page does not exist)"><script>evil()</script></a>',
126 $linkRenderer->makeLink( $foobar,
'<script>evil()</script>' )
130 '<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar '
131 .
'(page does not exist)"><script>evil()</script></a>',
136 public function testGetLinkClasses() {
138 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
139 $linkCache =
new LinkCache( $titleFormatter, $wanCache );
143 $linkCache->addGoodLinkObj(
149 $linkCache->addGoodLinkObj(
156 $linkCache->addGoodLinkObj(