jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/358163 )
Change subject: Rename canTalk methods
......................................................................
Rename canTalk methods
This renames Title::canTalk to Title::canHaveTalkPage
and MWNamespace::canTalk to MWNamespace::hasTalkNamespace.
Bug: T165149
Change-Id: I342a273a497b31282388b13bf76dadfb1122dcbb
---
M RELEASE-NOTES-1.30
M includes/MWNamespace.php
M includes/Title.php
M tests/phpunit/includes/MWNamespaceTest.php
M tests/phpunit/includes/TitleTest.php
5 files changed, 111 insertions(+), 17 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30
index f2cb871..79f3dc3 100644
--- a/RELEASE-NOTES-1.30
+++ b/RELEASE-NOTES-1.30
@@ -85,6 +85,10 @@
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.
diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php
index 4c5561f..89cb616 100644
--- a/includes/MWNamespace.php
+++ b/includes/MWNamespace.php
@@ -278,12 +278,26 @@
}
/**
- * 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;
}
diff --git a/includes/Title.php b/includes/Title.php
index c9f09f7..2ebeb0d 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -1020,12 +1020,25 @@
}
/**
- * 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 );
}
/**
diff --git a/tests/phpunit/includes/MWNamespaceTest.php
b/tests/phpunit/includes/MWNamespaceTest.php
index 5977652..498532f 100644
--- a/tests/phpunit/includes/MWNamespaceTest.php
+++ b/tests/phpunit/includes/MWNamespaceTest.php
@@ -262,21 +262,43 @@
}
*/
+ 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" );
}
/**
diff --git a/tests/phpunit/includes/TitleTest.php
b/tests/phpunit/includes/TitleTest.php
index 6c44999..c06a2e4 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -675,6 +675,47 @@
);
}
+ 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' ],
--
To view, visit https://gerrit.wikimedia.org/r/358163
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I342a273a497b31282388b13bf76dadfb1122dcbb
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits