Merge "DatabaseMssql: Don't duplicate body of makeList()"
[lhc/web/wiklou.git] / tests / phpunit / includes / title / NamespaceAwareForeignTitleFactoryTest.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 NamespaceAwareForeignTitleFactory
25 *
26 * @group Title
27 */
28 class NamespaceAwareForeignTitleFactoryTest extends MediaWikiTestCase {
29
30 public function basicProvider() {
31 return array(
32 array(
33 'MainNamespaceArticle', 0,
34 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
35 ),
36 array(
37 'MainNamespaceArticle', null,
38 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
39 ),
40 array(
41 'Talk:Nice_talk', 1,
42 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
43 ),
44 array(
45 'Bogus:Nice_talk', 0,
46 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
47 ),
48 array(
49 'Bogus:Nice_talk', null,
50 new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
51 ),
52 array(
53 'Bogus:Nice_talk', 4,
54 new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
55 ),
56 array(
57 'Bogus:Nice_talk', 1,
58 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
59 ),
60 );
61 }
62
63 /**
64 * @dataProvider basicProvider
65 */
66 public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
67
68 $foreignNamespaces = array(
69 0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
70 );
71
72 $factory = new NamespaceAwareForeignTitleFactory( $foreignNamespaces );
73 $testTitle = $factory->createForeignTitle( $title, $ns );
74
75 $this->assertEquals( $testTitle->isNamespaceIdKnown(),
76 $foreignTitle->isNamespaceIdKnown() );
77
78 if (
79 $testTitle->isNamespaceIdKnown() &&
80 $foreignTitle->isNamespaceIdKnown()
81 ) {
82 $this->assertEquals( $testTitle->getNamespaceId(),
83 $foreignTitle->getNamespaceId() );
84 }
85
86 $this->assertEquals( $testTitle->getNamespaceName(),
87 $foreignTitle->getNamespaceName() );
88 $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
89 }
90 }