MediaWiki  REL1_31
Go to the documentation of this file.
1 <?php
29  protected function setUp() {
30  parent::setUp();
32  $this->setMwGlobals( [
33  'wgLanguageCode' => 'en',
34  'wgContLang' => Language::factory( 'en' ),
35  ] );
36  }
38  public function basicProvider() {
39  return [
40  [
41  new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
42  0,
43  'MainNamespaceArticle'
44  ],
45  [
46  new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
47  2,
48  'User:MainNamespaceArticle'
49  ],
50  [
51  new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
52  0,
53  'Nice_talk'
54  ],
55  [
56  new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
57  0,
58  'Bogus:Nice_talk'
59  ],
60  [
61  new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
62  2,
63  'User:Bogus:Nice_talk'
64  ],
65  ];
66  }
71  public function testBasic( ForeignTitle $foreignTitle, $ns, $titleText ) {
72  $factory = new NamespaceImportTitleFactory( $ns );
73  $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
74  $title = Title::newFromText( $titleText );
76  $this->assertTrue( $title->equals( $testTitle ) );
77  }
78 }
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
Definition: NamespaceImportTitleFactoryTest.php:38
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Definition: NamespaceImportTitleFactory.php:26
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
Definition: NamespaceImportTitleFactoryTest.php:29
testBasic(ForeignTitle $foreignTitle, $ns, $titleText)
Definition: NamespaceImportTitleFactoryTest.php:71
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:678
Definition: MediaWikiTestCase.php:17
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
Definition: NamespaceImportTitleFactoryTest.php:27
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Definition: ForeignTitle.php:28