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.
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.
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
19 * @author This, that and the other
23 * @covers NamespaceAwareForeignTitleFactory
27 class NamespaceAwareForeignTitleFactoryTest
extends MediaWikiTestCase
{
29 public function basicProvider() {
32 'MainNamespaceArticle', 0,
33 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
36 'MainNamespaceArticle', null,
37 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
40 'Magic:_The_Gathering', 0,
41 new ForeignTitle( 0, '', 'Magic:_The_Gathering' ),
45 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
48 'Talk:Magic:_The_Gathering', 1,
49 new ForeignTitle( 1, 'Talk', 'Magic:_The_Gathering' ),
53 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
56 'Bogus:Nice_talk', null,
57 new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
61 new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
65 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
67 // Misconfigured wiki with unregistered namespace (T114115)
70 new ForeignTitle( 1234, 'Ns1234', 'Nice_talk' ),
76 * @dataProvider basicProvider
78 public function testBasic( $title, $ns, ForeignTitle
$foreignTitle ) {
79 $foreignNamespaces = [
80 0 => '', 1 => 'Talk', 100 => 'Portal', 9000 => 'Bogus'
83 $factory = new NamespaceAwareForeignTitleFactory( $foreignNamespaces );
84 $testTitle = $factory->createForeignTitle( $title, $ns );
86 $this->assertEquals( $testTitle->isNamespaceIdKnown(),
87 $foreignTitle->isNamespaceIdKnown() );
90 $testTitle->isNamespaceIdKnown() &&
91 $foreignTitle->isNamespaceIdKnown()
93 $this->assertEquals( $testTitle->getNamespaceId(),
94 $foreignTitle->getNamespaceId() );
97 $this->assertEquals( $testTitle->getNamespaceName(),
98 $foreignTitle->getNamespaceName() );
99 $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );