MediaWiki REL1_32
LinkRendererFactoryTest.php
Go to the documentation of this file.
1<?php
2
6
11
16
20 private $linkCache;
21
22 public function setUp() {
23 parent::setUp();
24 $this->titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
25 $this->linkCache = MediaWikiServices::getInstance()->getLinkCache();
26 }
27
28 public static function provideCreateFromLegacyOptions() {
29 return [
30 [
31 [ 'forcearticlepath' ],
32 'getForceArticlePath',
33 true
34 ],
35 [
36 [ 'http' ],
37 'getExpandURLs',
39 ],
40 [
41 [ 'https' ],
42 'getExpandURLs',
44 ],
45 [
46 [ 'stubThreshold' => 150 ],
47 'getStubThreshold',
48 150
49 ],
50 ];
51 }
52
56 public function testCreateFromLegacyOptions( $options, $func, $val ) {
57 $factory = new LinkRendererFactory( $this->titleFormatter, $this->linkCache );
58 $linkRenderer = $factory->createFromLegacyOptions(
60 );
61 $this->assertInstanceOf( LinkRenderer::class, $linkRenderer );
62 $this->assertEquals( $val, $linkRenderer->$func(), $func );
63 }
64
65 public function testCreate() {
66 $factory = new LinkRendererFactory( $this->titleFormatter, $this->linkCache );
67 $this->assertInstanceOf( LinkRenderer::class, $factory->create() );
68 }
69
70 public function testCreateForUser() {
72 $user = $this->getMockBuilder( User::class )
73 ->setMethods( [ 'getStubThreshold' ] )->getMock();
74 $user->expects( $this->once() )
75 ->method( 'getStubThreshold' )
76 ->willReturn( 15 );
77 $factory = new LinkRendererFactory( $this->titleFormatter, $this->linkCache );
78 $linkRenderer = $factory->createForUser( $user );
79 $this->assertInstanceOf( LinkRenderer::class, $linkRenderer );
80 $this->assertEquals( 15, $linkRenderer->getStubThreshold() );
81 }
82}
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:34
MediaWiki\Linker\LinkRendererFactory.
testCreateFromLegacyOptions( $options, $func, $val)
provideCreateFromLegacyOptions
Base class that store and restore the Language objects.
Factory to create LinkRender objects.
Class that generates HTML links for pages.
MediaWikiServices is the service locator for the application scope of MediaWiki.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2050
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2055
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition hooks.txt:2105
const PROTO_HTTPS
Definition Defines.php:220
const PROTO_HTTP
Definition Defines.php:219
A title formatter service for MediaWiki.