Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / title / NaiveForeignTitleFactoryTest.php
blobb8cc39f0543856fb7082e91e390f4159ab5277d1
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.
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
18 * @file
19 * @author This, that and the other
22 /**
23 * @covers NaiveForeignTitleFactory
25 * @group Title
27 class NaiveForeignTitleFactoryTest extends MediaWikiTestCase {
29 public function basicProvider() {
30 return [
32 'MainNamespaceArticle', 0,
33 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
36 'MainNamespaceArticle', null,
37 new ForeignTitle( null, '', 'MainNamespaceArticle' ),
40 'Talk:Nice_talk', 1,
41 new ForeignTitle( 1, 'Talk', 'Nice_talk' ),
44 'Bogus:Nice_talk', 0,
45 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
48 'Bogus:Nice_talk', 9000, // non-existent local namespace ID
49 new ForeignTitle( 9000, 'Bogus', 'Nice_talk' ),
52 'Bogus:Nice_talk', 4, // existing local namespace ID
53 new ForeignTitle( 4, 'Bogus', 'Nice_talk' ),
56 'Talk:Extra:Nice_talk', 1,
57 new ForeignTitle( 1, 'Talk', 'Extra:Nice_talk' ),
60 'Talk:Extra:Nice_talk', null,
61 new ForeignTitle( null, 'Talk', 'Extra:Nice_talk' ),
66 /**
67 * @dataProvider basicProvider
69 public function testBasic( $title, $ns, ForeignTitle $foreignTitle ) {
70 $factory = new NaiveForeignTitleFactory();
71 $testTitle = $factory->createForeignTitle( $title, $ns );
73 $this->assertEquals( $testTitle->isNamespaceIdKnown(),
74 $foreignTitle->isNamespaceIdKnown() );
76 if (
77 $testTitle->isNamespaceIdKnown() &&
78 $foreignTitle->isNamespaceIdKnown()
79 ) {
80 $this->assertEquals( $testTitle->getNamespaceId(),
81 $foreignTitle->getNamespaceId() );
84 $this->assertEquals( $testTitle->getNamespaceName(),
85 $foreignTitle->getNamespaceName() );
86 $this->assertEquals( $testTitle->getText(), $foreignTitle->getText() );
88 $this->assertEquals( str_replace( ' ', '_', $title ),
89 $foreignTitle->getFullText() );