MediaWiki  1.27.1
NaiveImportTitleFactoryTest.php
Go to the documentation of this file.
1 <?php
28 
29  protected function setUp() {
30  parent::setUp();
31 
32  $this->setMwGlobals( [
33  'wgLanguageCode' => 'en',
34  'wgContLang' => Language::factory( 'en' ),
35  'wgExtraNamespaces' => [ 100 => 'Portal' ],
36  ] );
37  }
38 
39  public function basicProvider() {
40  return [
41  [
42  new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
43  Title::newFromText( 'MainNamespaceArticle' )
44  ],
45  [
46  new ForeignTitle( null, '', 'MainNamespaceArticle' ),
47  Title::newFromText( 'MainNamespaceArticle' )
48  ],
49  [
50  new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
51  Title::newFromText( 'Talk:Nice_talk' )
52  ],
53  [
54  new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
55  Title::newFromText( 'Bogus:Nice_talk' )
56  ],
57  [
58  new ForeignTitle( 100, 'Bogus', 'Nice_talk' ),
59  Title::newFromText( 'Bogus:Nice_talk' ) // not Portal:Nice_talk
60  ],
61  [
62  new ForeignTitle( 1, 'Bogus', 'Nice_talk' ),
63  Title::newFromText( 'Talk:Nice_talk' ) // not Bogus:Nice_talk
64  ],
65  [
66  new ForeignTitle( 100, 'Portal', 'Nice_talk' ),
67  Title::newFromText( 'Portal:Nice_talk' )
68  ],
69  [
70  new ForeignTitle( 724, 'Portal', 'Nice_talk' ),
71  Title::newFromText( 'Portal:Nice_talk' )
72  ],
73  [
74  new ForeignTitle( 2, 'Portal', 'Nice_talk' ),
75  Title::newFromText( 'User:Nice_talk' )
76  ],
77  ];
78  }
79 
83  public function testBasic( ForeignTitle $foreignTitle, Title $title ) {
85  $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
86 
87  $this->assertTrue( $title->equals( $testTitle ) );
88  }
89 }
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
Represents a title within MediaWiki.
Definition: Title.php:34
$factory
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
equals(Title $title)
Compare with another title.
Definition: Title.php:4202
testBasic(ForeignTitle $foreignTitle, Title $title)
basicProvider
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:35
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
static factory($code)
Get a cached or new language object for a given language code.
Definition: Language.php:179
setMwGlobals($pairs, $value=null)