Merge "UnregisteredLocalFile.php: Override File::getBitDepth() stub"
[lhc/web/wiklou.git] / tests / phpunit / includes / title / ForeignTitleTest.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @license GPL 2+
20 * @author This, that and the other
21 */
22
23 /**
24 * @covers ForeignTitle
25 *
26 * @group Title
27 */
28 class ForeignTitleTest extends MediaWikiTestCase {
29
30 public function basicProvider() {
31 return array(
32 array(
33 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
34 20, 'Contributor', 'JohnDoe'
35 ),
36 array(
37 new ForeignTitle( '1', 'Discussion', 'Capital' ),
38 1, 'Discussion', 'Capital'
39 ),
40 array(
41 new ForeignTitle( 0, '', 'MainNamespace' ),
42 0, '', 'MainNamespace'
43 ),
44 array(
45 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
46 4, 'Some_ns', 'Article_title_with_spaces'
47 ),
48 );
49 }
50
51 /**
52 * @dataProvider basicProvider
53 */
54 public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
55 $expectedText ) {
56
57 $this->assertEquals( true, $title->isNamespaceIdKnown() );
58 $this->assertEquals( $expectedId, $title->getNamespaceId() );
59 $this->assertEquals( $expectedName, $title->getNamespaceName() );
60 $this->assertEquals( $expectedText, $title->getText() );
61 }
62
63 public function testUnknownNamespaceCheck( ) {
64 $title = new ForeignTitle( null, 'this', 'that' );
65
66 $this->assertEquals( false, $title->isNamespaceIdKnown() );
67 $this->assertEquals( 'this', $title->getNamespaceName() );
68 $this->assertEquals( 'that', $title->getText() );
69 }
70
71 public function testUnknownNamespaceError( ) {
72 $this->setExpectedException( 'MWException' );
73 $title = new ForeignTitle( null, 'this', 'that' );
74 $title->getNamespaceId();
75 }
76
77 public function fullTextProvider() {
78 return array(
79 array(
80 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
81 'Contributor:JohnDoe'
82 ),
83 array(
84 new ForeignTitle( '1', 'Discussion', 'Capital' ),
85 'Discussion:Capital'
86 ),
87 array(
88 new ForeignTitle( 0, '', 'MainNamespace' ),
89 'MainNamespace'
90 ),
91 array(
92 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
93 'Some_ns:Article_title_with_spaces'
94 ),
95 );
96 }
97
98 /**
99 * @dataProvider fullTextProvider
100 */
101 public function testFullText( ForeignTitle $title, $fullText ) {
102 $this->assertEquals( $fullText, $title->getFullText() );
103 }
104 }