MediaWiki REL1_28
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->getMock( User::class, [ 'getStubThreshold' ] );
73 $user->expects( $this->once() )
74 ->method( 'getStubThreshold' )
75 ->willReturn( 15 );
76 $factory = new LinkRendererFactory( $this->titleFormatter, $this->linkCache );
77 $linkRenderer = $factory->createForUser( $user );
78 $this->assertInstanceOf( LinkRenderer::class, $linkRenderer );
79 $this->assertEquals( 15, $linkRenderer->getStubThreshold() );
80 }
81}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:31
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.
const PROTO_HTTPS
Definition Defines.php:224
const PROTO_HTTP
Definition Defines.php:223
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1096
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:1950
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:1990
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
A title formatter service for MediaWiki.