MediaWiki REL1_33
NaiveForeignTitleFactoryTest.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( null, '', 'MainNamespaceArticle' ),
38 ],
39 [
40 'Talk:Nice_talk', 1,
41 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
42 ],
43 [
44 'Bogus:Nice_talk', 0,
45 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
46 ],
47 [
48 'Bogus:Nice_talk', 9000, // non-existent local namespace ID
49 new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
50 ],
51 [
52 'Bogus:Nice_talk', 4, // existing local namespace ID
53 new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
54 ],
55 [
56 'Talk:Extra:Nice_talk', 1,
57 new ForeignTitle( 1, 'Talk', 'Extra:Nice_talk' ),
58 ],
59 [
60 'Talk:Extra:Nice_talk', null,
61 new ForeignTitle( null, 'Talk', 'Extra:Nice_talk' ),
62 ],
63 ];
64 }
65
69 public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
70 $factory = new NaiveForeignTitleFactory();
71 $testTitle = $factory->createForeignTitle( $title, $ns );
72
73 $this->assertEquals( $testTitle->isNamespaceIdKnown(),
74 $foreignTitle->isNamespaceIdKnown() );
75
76 if (
77 $testTitle->isNamespaceIdKnown() &&
78 $foreignTitle->isNamespaceIdKnown()
79 ) {
80 $this->assertEquals( $testTitle->getNamespaceId(),
81 $foreignTitle->getNamespaceId() );
82 }
83
84 $this->assertEquals( $testTitle->getNamespaceName(),
85 $foreignTitle->getNamespaceName() );
86 $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
87
88 $this->assertEquals( str_replace( ' ', '_', $title ),
89 $foreignTitle->getFullText() );
90 }
91}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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, with no knowledge o...