MediaWiki REL1_31
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::class );
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)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
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:39