70 $this->assertTrue( in_array(
'foobar', $site->
getInterwikiIds(),
true ) );
117 $this->assertEquals(
'foobar', $site->
getGlobalId() );
126 $this->assertInternalType(
'string', $site->
getType() );
146 $this->assertInternalType(
'array', $site->
getAllPaths() );
158 $site->
setPath(
'spam',
'http://www.wikidata.org/$1' );
159 $site->
setPath(
'spam',
'http://www.wikidata.org/foo/$1' );
160 $site->
setPath(
'foobar',
'http://www.wikidata.org/bar/$1' );
162 $this->assertEquals( $count + 2, count( $site->
getAllPaths() ) );
164 $this->assertInternalType(
'string', $site->
getPath(
'foobar' ) );
165 $this->assertEquals(
'http://www.wikidata.org/foo/$1', $site->
getPath(
'spam' ) );
170 $this->assertEquals( $count, count( $site->
getAllPaths() ) );
172 $this->assertNull( $site->
getPath(
'foobar' ) );
173 $this->assertNull( $site->
getPath(
'spam' ) );
181 $path =
"TestPath/$1";
183 $site->setLinkPath(
$path );
184 $this->assertEquals(
$path, $site->getLinkPath() );
193 $path =
'TestPath/$1';
194 $site->setLinkPath(
$path );
195 $this->assertEquals(
$path, $site->getPath( $site->getLinkPathType() ) );
197 $path =
'AnotherPath/$1';
198 $site->setPath( $site->getLinkPathType(),
$path );
199 $this->assertEquals(
$path, $site->getLinkPath() );
208 $path =
'TestPath/$1';
209 $site->setPath(
'foo',
$path );
211 $this->assertEquals(
$path, $site->getPath(
'foo' ) );
221 $type = $site->getLinkPathType();
222 $path =
'//acme.com/';
225 $this->assertEquals(
'', $site->getProtocol() );
236 'http://acme.test/TestPath/$1',
241 'http://acme.test/TestScript?x=$1&y=bla',
243 'TestScript?x=Foo&y=bla',
246 'http://acme.test/TestPath/$1',
247 'foo & bar/xyzzy (quux-shmoox?)',
248 '/TestPath/foo%20%26%20bar%2Fxyzzy%20%28quux-shmoox%3F%29',
263 $site->setLinkPath(
$path );
264 $this->assertContains(
$path, $site->getPageUrl() );
266 $this->assertContains( $expected, $site->getPageUrl( $page ) );
271 $this->assertTrue(
true );
284 $this->assertInstanceOf( Serializable::class, $site );
289 $this->assertInstanceOf( Site::class, $newInstance );
291 $this->assertEquals( $serialization,
serialize( $newInstance ) );
unserialize( $serialized)
testGetGlobalId(Site $site)
instanceProvider
assertTypeOrFalse( $type, $value)
testGetLanguageCode(Site $site)
instanceProvider
testProtocolRelativePath()
Site::setPath Site::getProtocol.
testNormalizePageName(Site $site)
instanceProvider
testSetLanguageCode(Site $site)
instanceProvider
testGetAllPaths(Site $site)
instanceProvider
testAddInterwikiId(Site $site)
instanceProvider
testGetPageUrl( $path, $page, $expected)
provideGetPageUrl Site::getPageUrl
testGetNavigationIds(Site $site)
instanceProvider
testGetLinkPathType()
Site::getLinkPathType.
testSetLinkPath()
Site::setLinkPath.
static provideGetPageUrl()
testGetType(Site $site)
instanceProvider
testSetAndRemovePath(Site $site)
instanceProvider
testSetPath()
Site::setPath.
testGetInterwikiIds(Site $site)
instanceProvider
testGetPath(Site $site)
instanceProvider
testSerialization(Site $site)
instanceProvider
testSetGlobalId(Site $site)
instanceProvider
testAddNavigationId(Site $site)
instanceProvider
normalizePageName( $pageName)
Attempt to normalize the page name in some fashion.
setPath( $pathType, $fullUrl)
Sets the path used to construct links with.
addInterwikiId( $identifier)
Adds an interwiki id to the site.
getPath( $pathType)
Returns the path of the provided type or false if there is no such path.
getType()
Returns the type of the site (ie mediawiki).
removePath( $pathType)
Removes the path of the provided type if it's set.
setLanguageCode( $languageCode)
Sets language code of the sites primary language.
getGlobalId()
Returns the global site identifier (ie enwiktionary).
setGlobalId( $globalId)
Sets the global site identifier (ie enwiktionary).
addNavigationId( $identifier)
Adds a navigation id to the site.
getAllPaths()
Returns the paths as associative array.
getLanguageCode()
Returns language code of the sites primary language.
getNavigationIds()
Returns the equivalent link identifiers that can be used to make the site show up in interfaces such ...
getInterwikiIds()
Returns the interwiki link identifiers that can be used for this site.
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