public function testCreateForUser()
 {
     $user = $this->getMock(User::class, ['getStubThreshold']);
     $user->expects($this->once())->method('getStubThreshold')->willReturn(15);
     $factory = new LinkRendererFactory($this->titleFormatter);
     $linkRenderer = $factory->createForUser($user);
     $this->assertInstanceOf(LinkRenderer::class, $linkRenderer);
     $this->assertEquals(15, $linkRenderer->getStubThreshold());
 }
Exemplo n.º 2
0
 public function testCreateForUser()
 {
     /** @var PHPUnit_Framework_MockObject_MockObject|User $user */
     $user = $this->getMock(User::class, ['getStubThreshold']);
     $user->expects($this->once())->method('getStubThreshold')->willReturn(15);
     $factory = new LinkRendererFactory($this->titleFormatter, $this->linkCache);
     $linkRenderer = $factory->createForUser($user);
     $this->assertInstanceOf(LinkRenderer::class, $linkRenderer);
     $this->assertEquals(15, $linkRenderer->getStubThreshold());
 }
Exemplo n.º 3
0
 public function testMakeLink()
 {
     $linkRenderer = $this->factory->create();
     $foobar = new TitleValue(NS_SPECIAL, 'Foobar');
     $blankpage = new TitleValue(NS_SPECIAL, 'Blankpage');
     $this->assertEquals('<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar ' . '(page does not exist)">foo</a>', $linkRenderer->makeLink($foobar, 'foo'));
     $this->assertEquals('<a href="/wiki/Special:BlankPage" title="Special:BlankPage">blank</a>', $linkRenderer->makeLink($blankpage, 'blank'));
     $this->assertEquals('<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar ' . '(page does not exist)">&lt;script&gt;evil()&lt;/script&gt;</a>', $linkRenderer->makeLink($foobar, '<script>evil()</script>'));
     $this->assertEquals('<a href="/wiki/Special:Foobar" class="new" title="Special:Foobar ' . '(page does not exist)"><script>evil()</script></a>', $linkRenderer->makeLink($foobar, new HtmlArmor('<script>evil()</script>')));
 }