MediaWiki REL1_30
NamespaceAwareForeignTitleFactoryTest.php
Go to the documentation of this file.
1<?php
28
29 public function basicProvider() {
30 return [
31 [
32 'MainNamespaceArticle', 0,
33 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
34 ],
35 [
36 'MainNamespaceArticle', null,
37 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
38 ],
39 [
40 'Magic:_The_Gathering', 0,
41 new ForeignTitle( 0, '', 'Magic:_The_Gathering' ),
42 ],
43 [
44 'Talk:Nice_talk', 1,
45 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
46 ],
47 [
48 'Talk:Magic:_The_Gathering', 1,
49 new ForeignTitle( 1, 'Talk', 'Magic:_The_Gathering' ),
50 ],
51 [
52 'Bogus:Nice_talk', 0,
53 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
54 ],
55 [
56 'Bogus:Nice_talk', null,
57 new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
58 ],
59 [
60 'Bogus:Nice_talk', 4,
61 new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
62 ],
63 [
64 'Bogus:Nice_talk', 1,
65 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
66 ],
67 // Misconfigured wiki with unregistered namespace (T114115)
68 [
69 'Nice_talk', 1234,
70 new ForeignTitle( 1234, 'Ns1234', 'Nice_talk' ),
71 ],
72 ];
73 }
74
78 public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
79 $foreignNamespaces = [
80 0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
81 ];
82
83 $factory = new NamespaceAwareForeignTitleFactory( $foreignNamespaces );
84 $testTitle = $factory->createForeignTitle( $title, $ns );
85
86 $this->assertEquals( $testTitle->isNamespaceIdKnown(),
87 $foreignTitle->isNamespaceIdKnown() );
88
89 if (
90 $testTitle->isNamespaceIdKnown() &&
91 $foreignTitle->isNamespaceIdKnown()
92 ) {
93 $this->assertEquals( $testTitle->getNamespaceId(),
94 $foreignTitle->getNamespaceId() );
95 }
96
97 $this->assertEquals( $testTitle->getNamespaceName(),
98 $foreignTitle->getNamespaceName() );
99 $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
100 }
101}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
testBasic( $title, $ns, ForeignTitle $foreignTitle)
basicProvider
A parser that translates page titles on a foreign wiki into ForeignTitle objects, using information a...