Merge "resourceloader: Fix typo in comment to make more sense"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
index f36fbfd..35b196a 100644 (file)
@@ -289,7 +289,6 @@ class TitleTest extends MediaWikiTestCase {
         * @param array|string|bool $expected Required error
         * @dataProvider provideTestIsValidMoveOperation
         * @covers Title::isValidMoveOperation
-        * @covers Title::validateFileMoveOperation
         */
        public function testIsValidMoveOperation( $source, $target, $expected ) {
                $this->setMwGlobals( 'wgContentHandlerUseDB', false );
@@ -315,7 +314,6 @@ class TitleTest extends MediaWikiTestCase {
                        [ 'Test', 'Special:FooBar', 'immobile-target-namespace' ],
                        [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ],
                        [ 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ],
-                       // for Title::validateFileMoveOperation
                        [ 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ],
                ];
        }
@@ -730,18 +728,6 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertSame( $expected, $actual, $title->getPrefixedDBkey() );
        }
 
-       /**
-        * @dataProvider provideCanHaveTalkPage
-        * @covers Title::canTalk
-        *
-        * @param Title $title
-        * @param bool $expected
-        */
-       public function testCanTalk( Title $title, $expected ) {
-               $actual = $title->canTalk();
-               $this->assertSame( $expected, $actual, $title->getPrefixedDBkey() );
-       }
-
        public static function provideGetTalkPage_good() {
                return [
                        [ Title::makeTitle( NS_MAIN, 'Test' ), Title::makeTitle( NS_TALK, 'Test' ) ],
@@ -995,4 +981,93 @@ class TitleTest extends MediaWikiTestCase {
                        [ 'Main Page', false ],
                ];
        }
+
+       public function provideEquals() {
+               yield [
+                       Title::newFromText( 'Main Page' ),
+                       Title::newFromText( 'Main Page' ),
+                       true
+               ];
+               yield [
+                       Title::newFromText( 'Main Page' ),
+                       Title::newFromText( 'Not The Main Page' ),
+                       false
+               ];
+               yield [
+                       Title::newFromText( 'Main Page' ),
+                       Title::newFromText( 'Project:Main Page' ),
+                       false
+               ];
+               yield [
+                       Title::newFromText( 'File:Example.png' ),
+                       Title::newFromText( 'Image:Example.png' ),
+                       true
+               ];
+               yield [
+                       Title::newFromText( 'Special:Version' ),
+                       Title::newFromText( 'Special:Version' ),
+                       true
+               ];
+               yield [
+                       Title::newFromText( 'Special:Version' ),
+                       Title::newFromText( 'Special:Recentchanges' ),
+                       false
+               ];
+               yield [
+                       Title::newFromText( 'Special:Version' ),
+                       Title::newFromText( 'Main Page' ),
+                       false
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       true
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       Title::makeTitle( NS_MAIN, 'Bar', '', '' ),
+                       false
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       Title::makeTitle( NS_TALK, 'Foo', '', '' ),
+                       false
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+                       true
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', 'Baz', '' ),
+                       true
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       true
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+                       true
+               ];
+               yield [
+                       Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+                       Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+                       false
+               ];
+       }
+
+       /**
+        * @covers Title::equals
+        * @dataProvider provideEquals
+        */
+       public function testEquals( Title $firstValue, /* LinkTarget */ $secondValue, $expectedSame ) {
+               $this->assertSame(
+                       $expectedSame,
+                       $firstValue->equals( $secondValue )
+               );
+       }
 }