Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / includes / title / TitleValueTest.php
blob3ba008d6c4c1a1fdd5f2e730aab50736bb2faeea
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 * @license GPL 2+
20 * @author Daniel Kinzler
23 /**
24 * @covers TitleValue
26 * @group Title
28 class TitleValueTest extends MediaWikiTestCase {
30 public function testConstruction() {
31 $title = new TitleValue( NS_USER, 'TestThis', 'stuff' );
33 $this->assertEquals( NS_USER, $title->getNamespace() );
34 $this->assertEquals( 'TestThis', $title->getText() );
35 $this->assertEquals( 'stuff', $title->getFragment() );
38 public function badConstructorProvider() {
39 return array(
40 array( 'foo', 'title', 'fragment' ),
41 array( null, 'title', 'fragment' ),
42 array( 2.3, 'title', 'fragment' ),
44 array( NS_MAIN, 5, 'fragment' ),
45 array( NS_MAIN, null, 'fragment' ),
46 array( NS_MAIN, '', 'fragment' ),
47 array( NS_MAIN, 'foo bar', '' ),
48 array( NS_MAIN, 'bar_', '' ),
49 array( NS_MAIN, '_foo', '' ),
50 array( NS_MAIN, ' eek ', '' ),
52 array( NS_MAIN, 'title', 5 ),
53 array( NS_MAIN, 'title', null ),
54 array( NS_MAIN, 'title', array() ),
58 /**
59 * @dataProvider badConstructorProvider
61 public function testConstructionErrors( $ns, $text, $fragment ) {
62 $this->setExpectedException( 'InvalidArgumentException' );
63 new TitleValue( $ns, $text, $fragment );
66 public function fragmentTitleProvider() {
67 return array(
68 array( new TitleValue( NS_MAIN, 'Test' ), 'foo' ),
69 array( new TitleValue( NS_TALK, 'Test', 'foo' ), '' ),
70 array( new TitleValue( NS_CATEGORY, 'Test', 'foo' ), 'bar' ),
74 /**
75 * @dataProvider fragmentTitleProvider
77 public function testCreateFragmentTitle( TitleValue $title, $fragment ) {
78 $fragmentTitle = $title->createFragmentTitle( $fragment );
80 $this->assertEquals( $title->getNamespace(), $fragmentTitle->getNamespace() );
81 $this->assertEquals( $title->getText(), $fragmentTitle->getText() );
82 $this->assertEquals( $fragment, $fragmentTitle->getFragment() );
85 public function getTextProvider() {
86 return array(
87 array( 'Foo', 'Foo' ),
88 array( 'Foo_Bar', 'Foo Bar' ),
92 /**
93 * @dataProvider getTextProvider
95 public function testGetText( $dbkey, $text ) {
96 $title = new TitleValue( NS_MAIN, $dbkey );
98 $this->assertEquals( $text, $title->getText() );