Merge "Linked HTML representation of a format to formatted output"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
index 496f18f..6c44999 100644 (file)
@@ -90,6 +90,8 @@ class TitleTest extends MediaWikiTestCase {
                        [ 'A < B', 'title-invalid-characters' ],
                        [ 'A > B', 'title-invalid-characters' ],
                        [ 'A | B', 'title-invalid-characters' ],
+                       [ "A \t B", 'title-invalid-characters' ],
+                       [ "A \n B", 'title-invalid-characters' ],
                        // URL encoding
                        [ 'A%20B', 'title-invalid-characters' ],
                        [ 'A%23B', 'title-invalid-characters' ],
@@ -265,7 +267,7 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertEquals(
                        $expectedParam,
                        $par,
-                       "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter"
+                       "T33100 regression check: Title->fixSpecialName() should preserve parameter"
                );
        }
 
@@ -709,4 +711,90 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertEquals( $title->getInterwiki(), $fragmentTitle->getInterwiki() );
                $this->assertEquals( $fragment, $fragmentTitle->getFragment() );
        }
+
+       public function provideGetPrefixedText() {
+               return [
+                       // ns = 0
+                       [
+                               Title::makeTitle( NS_MAIN, 'Foo bar' ),
+                               'Foo bar'
+                       ],
+                       // ns = 2
+                       [
+                               Title::makeTitle( NS_USER, 'Foo bar' ),
+                               'User:Foo bar'
+                       ],
+                       // ns = 3
+                       [
+                               Title::makeTitle( NS_USER_TALK, 'Foo bar' ),
+                               'User talk:Foo bar'
+                       ],
+                       // fragment not included
+                       [
+                               Title::makeTitle( NS_MAIN, 'Foo bar', 'fragment' ),
+                               'Foo bar'
+                       ],
+                       // ns = -2
+                       [
+                               Title::makeTitle( NS_MEDIA, 'Foo bar' ),
+                               'Media:Foo bar'
+                       ],
+                       // non-existent namespace
+                       [
+                               Title::makeTitle( 100777, 'Foo bar' ),
+                               'Special:Badtitle/NS100777:Foo bar'
+                       ],
+               ];
+       }
+
+       /**
+        * @covers Title::getPrefixedText
+        * @dataProvider provideGetPrefixedText
+        */
+       public function testGetPrefixedText( Title $title, $expected ) {
+               $this->assertEquals( $expected, $title->getPrefixedText() );
+       }
+
+       public function provideGetPrefixedDBKey() {
+               return [
+                       // ns = 0
+                       [
+                               Title::makeTitle( NS_MAIN, 'Foo_bar' ),
+                               'Foo_bar'
+                       ],
+                       // ns = 2
+                       [
+                               Title::makeTitle( NS_USER, 'Foo_bar' ),
+                               'User:Foo_bar'
+                       ],
+                       // ns = 3
+                       [
+                               Title::makeTitle( NS_USER_TALK, 'Foo_bar' ),
+                               'User_talk:Foo_bar'
+                       ],
+                       // fragment not included
+                       [
+                               Title::makeTitle( NS_MAIN, 'Foo_bar', 'fragment' ),
+                               'Foo_bar'
+                       ],
+                       // ns = -2
+                       [
+                               Title::makeTitle( NS_MEDIA, 'Foo_bar' ),
+                               'Media:Foo_bar'
+                       ],
+                       // non-existent namespace
+                       [
+                               Title::makeTitle( 100777, 'Foo_bar' ),
+                               'Special:Badtitle/NS100777:Foo_bar'
+                       ],
+               ];
+       }
+
+       /**
+        * @covers Title::getPrefixedDBKey
+        * @dataProvider provideGetPrefixedDBKey
+        */
+       public function testGetPrefixedDBKey( Title $title, $expected ) {
+               $this->assertEquals( $expected, $title->getPrefixedDBkey() );
+       }
 }