Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / title / ForeignTitleTest.php
blobb6c242780778d3257d8264e7c504d45dddde63c9
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 ForeignTitle
25 * @group Title
27 class ForeignTitleTest extends MediaWikiTestCase {
29 public function basicProvider() {
30 return [
32 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
33 20, 'Contributor', 'JohnDoe'
36 new ForeignTitle( '1', 'Discussion', 'Capital' ),
37 1, 'Discussion', 'Capital'
40 new ForeignTitle( 0, '', 'MainNamespace' ),
41 0, '', 'MainNamespace'
44 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
45 4, 'Some_ns', 'Article_title_with_spaces'
50 /**
51 * @dataProvider basicProvider
53 public function testBasic( ForeignTitle $title, $expectedId, $expectedName,
54 $expectedText ) {
56 $this->assertEquals( true, $title->isNamespaceIdKnown() );
57 $this->assertEquals( $expectedId, $title->getNamespaceId() );
58 $this->assertEquals( $expectedName, $title->getNamespaceName() );
59 $this->assertEquals( $expectedText, $title->getText() );
62 public function testUnknownNamespaceCheck() {
63 $title = new ForeignTitle( null, 'this', 'that' );
65 $this->assertEquals( false, $title->isNamespaceIdKnown() );
66 $this->assertEquals( 'this', $title->getNamespaceName() );
67 $this->assertEquals( 'that', $title->getText() );
70 public function testUnknownNamespaceError() {
71 $this->setExpectedException( 'MWException' );
72 $title = new ForeignTitle( null, 'this', 'that' );
73 $title->getNamespaceId();
76 public function fullTextProvider() {
77 return [
79 new ForeignTitle( 20, 'Contributor', 'JohnDoe' ),
80 'Contributor:JohnDoe'
83 new ForeignTitle( '1', 'Discussion', 'Capital' ),
84 'Discussion:Capital'
87 new ForeignTitle( 0, '', 'MainNamespace' ),
88 'MainNamespace'
91 new ForeignTitle( 4, 'Some ns', 'Article title with spaces' ),
92 'Some_ns:Article_title_with_spaces'
97 /**
98 * @dataProvider fullTextProvider
100 public function testFullText( ForeignTitle $title, $fullText ) {
101 $this->assertEquals( $fullText, $title->getFullText() );