MediaWiki REL1_28
SubpageImportTitleFactoryTest.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 'wgNamespacesWithSubpages' => [ 0 => false, 2 => true ],
36 ] );
37 }
38
39 public function basicProvider() {
40 return [
41 [
42 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
43 Title::newFromText( 'User:Graham' ),
44 Title::newFromText( 'User:Graham/MainNamespaceArticle' )
45 ],
46 [
47 new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
48 Title::newFromText( 'User:Graham' ),
49 Title::newFromText( 'User:Graham/Discussion:Nice_talk' )
50 ],
51 [
52 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
53 Title::newFromText( 'User:Graham' ),
54 Title::newFromText( 'User:Graham/Bogus:Nice_talk' )
55 ],
56 ];
57 }
58
62 public function testBasic( ForeignTitle $foreignTitle, Title $rootPage,
63 Title $title ) {
64
65 $factory = new SubpageImportTitleFactory( $rootPage );
66 $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
67
68 $this->assertTrue( $testTitle->equals( $title ) );
69 }
70
71 public function failureProvider() {
72 return [
73 [
74 Title::newFromText( 'Graham' ),
75 ],
76 ];
77 }
78
82 public function testFailures( Title $rootPage ) {
83 $this->setExpectedException( 'MWException' );
84 new SubpageImportTitleFactory( $rootPage );
85 }
86}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
setMwGlobals( $pairs, $value=null)
testFailures(Title $rootPage)
failureProvider
testBasic(ForeignTitle $foreignTitle, Title $rootPage, Title $title)
basicProvider
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Represents a title within MediaWiki.
Definition Title.php:36
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
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