Rename canTalk methods

This renames Title::canTalk to Title::canHaveTalkPage
and MWNamespace::canTalk to MWNamespace::hasTalkNamespace.

Bug: T165149
Change-Id: I342a273a497b31282388b13bf76dadfb1122dcbb
This commit is contained in:
daniel 2017-06-09 20:29:18 +02:00 committed by Legoktm
parent da43a0ae34
commit f8ac44cca5
5 changed files with 111 additions and 17 deletions

View file

@ -85,6 +85,10 @@ changes to languages because of Phabricator reports.
deprecated. There are no known callers.
* File::getStreamHeaders() was deprecated.
* MediaHandler::getStreamHeaders() was deprecated.
* Title::canTalk() was deprecated, the new Title::canHaveTalkPage() should be
used instead.
* MWNamespace::canTalk() was deprecated, the new MWNamespace::hasTalkNamespace()
should be used instead.
* The ExtractThumbParameters hook (deprecated in 1.21) was removed.
* The OutputPage::addParserOutputNoText and ::getHeadLinks methods (both
deprecated in 1.24) were removed.

View file

@ -278,12 +278,26 @@ class MWNamespace {
}
/**
* Can this namespace ever have a talk namespace?
* Does this namespace ever have a talk namespace?
*
* @deprecated since 1.30, use hasTalkNamespace() instead.
*
* @param int $index Namespace index
* @return bool
* @return bool True if this namespace either is or has a corresponding talk namespace.
*/
public static function canTalk( $index ) {
return self::hasTalkNamespace( $index );
}
/**
* Does this namespace ever have a talk namespace?
*
* @since 1.30
*
* @param int $index Namespace ID
* @return bool True if this namespace either is or has a corresponding talk namespace.
*/
public static function hasTalkNamespace( $index ) {
return $index >= NS_MAIN;
}

View file

@ -1020,12 +1020,25 @@ class Title implements LinkTarget {
}
/**
* Could this title have a corresponding talk page?
* Can this title have a corresponding talk page?
*
* @return bool
* @deprecated since 1.30, use canHaveTalkPage() instead.
*
* @return bool True if this title either is a talk page or can have a talk page associated.
*/
public function canTalk() {
return MWNamespace::canTalk( $this->mNamespace );
return $this->canHaveTalkPage();
}
/**
* Can this title have a corresponding talk page?
*
* @see MWNamespace::hasTalkNamespace
*
* @return bool True if this title either is a talk page or can have a talk page associated.
*/
public function canHaveTalkPage() {
return MWNamespace::hasTalkNamespace( $this->mNamespace );
}
/**

View file

@ -262,21 +262,43 @@ class MWNamespaceTest extends MediaWikiTestCase {
}
*/
public function provideHasTalkNamespace() {
return [
[ NS_MEDIA, false ],
[ NS_SPECIAL, false ],
[ NS_MAIN, true ],
[ NS_TALK, true ],
[ NS_USER, true ],
[ NS_USER_TALK, true ],
[ 100, true ],
[ 101, true ],
];
}
/**
* @covers MWNamespace::canTalk
* @dataProvider provideHasTalkNamespace
* @covers MWNamespace::hasTalkNamespace
*
* @param int $index
* @param bool $expected
*/
public function testCanTalk() {
$this->assertCanNotTalk( NS_MEDIA );
$this->assertCanNotTalk( NS_SPECIAL );
public function testHasTalkNamespace( $index, $expected ) {
$actual = MWNamespace::hasTalkNamespace( $index );
$this->assertSame( $actual, $expected, "NS $index" );
}
$this->assertCanTalk( NS_MAIN );
$this->assertCanTalk( NS_TALK );
$this->assertCanTalk( NS_USER );
$this->assertCanTalk( NS_USER_TALK );
// User defined namespaces
$this->assertCanTalk( 100 );
$this->assertCanTalk( 101 );
/**
* @dataProvider provideHasTalkNamespace
* @covers MWNamespace::canTalk
*
* @param int $index
* @param bool $expected
*/
public function testCanTalk( $index, $expected ) {
$actual = MWNamespace::canTalk( $index );
$this->assertSame( $actual, $expected, "NS $index" );
}
/**

View file

@ -675,6 +675,47 @@ class TitleTest extends MediaWikiTestCase {
);
}
public function provideCanHaveTalkPage() {
return [
'User page has talk page' => [
Title::makeTitle( NS_USER, 'Jane' ), true
],
'Talke page has talk page' => [
Title::makeTitle( NS_TALK, 'Foo' ), true
],
'Special page cannot have talk page' => [
Title::makeTitle( NS_SPECIAL, 'Thing' ), false
],
'Virtual namespace cannot have talk page' => [
Title::makeTitle( NS_MEDIA, 'Kitten.jpg' ), false
],
];
}
/**
* @dataProvider provideCanHaveTalkPage
* @covers Title::canHaveTalkPage
*
* @param Title $title
* @param bool $expected
*/
public function testCanHaveTalkPage( Title $title, $expected ) {
$actual = $title->canHaveTalkPage();
$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 function provideCreateFragmentTitle() {
return [
[ Title::makeTitle( NS_MAIN, 'Test' ), 'foo' ],