MediaWiki REL1_32
ForeignTitleTest.php
Go to the documentation of this file.
1<?php
28
29 public function basicProvider() {
30 return [
31 [
32 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
33 20, 'Contributor', 'JohnDoe'
34 ],
35 [
36 new ForeignTitle( '1', 'Discussion', 'Capital' ),
37 1, 'Discussion', 'Capital'
38 ],
39 [
40 new ForeignTitle( 0, '', 'MainNamespace' ),
41 0, '', 'MainNamespace'
42 ],
43 [
44 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
45 4, 'Some_ns', 'Article_title_with_spaces'
46 ],
47 ];
48 }
49
53 public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
54 $expectedText
55 ) {
56 $this->assertEquals( true, $title->isNamespaceIdKnown() );
57 $this->assertEquals( $expectedId, $title->getNamespaceId() );
58 $this->assertEquals( $expectedName, $title->getNamespaceName() );
59 $this->assertEquals( $expectedText, $title->getText() );
60 }
61
62 public function testUnknownNamespaceCheck() {
63 $title = new ForeignTitle( null, 'this', 'that' );
64
65 $this->assertEquals( false, $title->isNamespaceIdKnown() );
66 $this->assertEquals( 'this', $title->getNamespaceName() );
67 $this->assertEquals( 'that', $title->getText() );
68 }
69
70 public function testUnknownNamespaceError() {
71 $this->setExpectedException( MWException::class );
72 $title = new ForeignTitle( null, 'this', 'that' );
73 $title->getNamespaceId();
74 }
75
76 public function fullTextProvider() {
77 return [
78 [
79 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
80 'Contributor:JohnDoe'
81 ],
82 [
83 new ForeignTitle( '1', 'Discussion', 'Capital' ),
84 'Discussion:Capital'
85 ],
86 [
87 new ForeignTitle( 0, '', 'MainNamespace' ),
88 'MainNamespace'
89 ],
90 [
91 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
92 'Some_ns:Article_title_with_spaces'
93 ],
94 ];
95 }
96
100 public function testFullText( ForeignTitle $title, $fullText ) {
101 $this->assertEquals( $fullText, $title->getFullText() );
102 }
103}
testFullText(ForeignTitle $title, $fullText)
fullTextProvider
testBasic(ForeignTitle $title, $expectedId, $expectedName, $expectedText)
basicProvider
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.