MediaWiki REL1_31
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 'MainNamespaceArticle'
44 ],
45 [
46 new ForeignTitle( null, '', 'MainNamespaceArticle' ),
47 'MainNamespaceArticle'
48 ],
49 [
50 new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
51 'Talk:Nice_talk'
52 ],
53 [
54 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
55 'Bogus:Nice_talk'
56 ],
57 [
58 new ForeignTitle( 100, 'Bogus', 'Nice_talk' ),
59 'Bogus:Nice_talk' // not Portal:Nice_talk
60 ],
61 [
62 new ForeignTitle( 1, 'Bogus', 'Nice_talk' ),
63 'Talk:Nice_talk' // not Bogus:Nice_talk
64 ],
65 [
66 new ForeignTitle( 100, 'Portal', 'Nice_talk' ),
67 'Portal:Nice_talk'
68 ],
69 [
70 new ForeignTitle( 724, 'Portal', 'Nice_talk' ),
71 'Portal:Nice_talk'
72 ],
73 [
74 new ForeignTitle( 2, 'Portal', 'Nice_talk' ),
75 'User:Nice_talk'
76 ],
77 ];
78 }
79
83 public function testBasic( ForeignTitle $foreignTitle, $titleText ) {
84 $factory = new NaiveImportTitleFactory();
85 $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
86 $title = Title::newFromText( $titleText );
87
88 $this->assertTrue( $title->equals( $testTitle ) );
89 }
90}
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.
testBasic(ForeignTitle $foreignTitle, $titleText)
basicProvider
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...