Use [...] instead of array(...) in PHP comments and documentation
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
index e29b7e7..529d9fb 100644 (file)
@@ -157,12 +157,8 @@ class TitleTest extends MediaWikiTestCase {
                        ]
                ] );
 
-               // Reset TitleParser since we modified $wgLocalInterwikis
-               $this->setService( 'TitleParser', new MediaWikiTitleCodec(
-                               Language::factory( 'en' ),
-                               new GenderCache(),
-                               [ 'localtestiw' ]
-               ) );
+               // Reset services since we modified $wgLocalInterwikis
+               $this->overrideMwServices();
        }
 
        /**
@@ -299,6 +295,8 @@ class TitleTest extends MediaWikiTestCase {
         * @covers Title::isValidMoveOperation
         */
        public function testIsValidMoveOperation( $source, $target, $expected ) {
+               $this->hideDeprecated( 'Title::isValidMoveOperation' );
+
                $this->setMwGlobals( 'wgContentHandlerUseDB', false );
                $title = Title::newFromText( $source );
                $nt = Title::newFromText( $target );
@@ -340,7 +338,7 @@ class TitleTest extends MediaWikiTestCase {
        public function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
                // $wgWhitelistReadRegexp must be an array. Since the provided test cases
                // usually have only one regex, it is more concise to write the lonely regex
-               // as a string. Thus we cast to an array() to honor $wgWhitelistReadRegexp
+               // as a string. Thus we cast to a [] to honor $wgWhitelistReadRegexp
                // type requisite.
                if ( is_string( $whitelistRegexp ) ) {
                        $whitelistRegexp = [ $whitelistRegexp ];
@@ -598,6 +596,27 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertTrue( $clone->equals( $title ) );
        }
 
+       public function provideCastFromLinkTarget() {
+               return array_merge( [ [ null ] ], self::provideNewFromTitleValue() );
+       }
+
+       /**
+        * @covers Title::castFromLinkTarget
+        * @dataProvider provideCastFromLinkTarget
+        */
+       public function testCastFromLinkTarget( $value ) {
+               $title = Title::castFromLinkTarget( $value );
+
+               if ( $value === null ) {
+                       $this->assertNull( $title );
+               } else {
+                       $dbkey = str_replace( ' ', '_', $value->getText() );
+                       $this->assertSame( $dbkey, $title->getDBkey() );
+                       $this->assertSame( $value->getNamespace(), $title->getNamespace() );
+                       $this->assertSame( $value->getFragment(), $title->getFragment() );
+               }
+       }
+
        public static function provideGetTitleValue() {
                return [
                        [ 'Foo' ],
@@ -769,19 +788,6 @@ class TitleTest extends MediaWikiTestCase {
                ];
        }
 
-       /**
-        * @dataProvider provideGetTalkPage_good
-        * @covers Title::getTalkPage
-        */
-       public function testGetTalkPage_good( Title $title, Title $expected ) {
-               $talk = $title->getTalkPage();
-               $this->assertSame(
-                       $expected->getPrefixedDBKey(),
-                       $talk->getPrefixedDBKey(),
-                       $title->getPrefixedDBKey()
-               );
-       }
-
        /**
         * @dataProvider provideGetTalkPage_good
         * @covers Title::getTalkPageIfDefined