Merge "ServiceWiring: Avoid usage of deprecated Title::getSubjectPage()"

This commit is contained in:
jenkins-bot 2020-08-10 21:41:21 +00:00 committed by Gerrit Code Review
commit e9b23132c3
3 changed files with 20 additions and 3 deletions

View file

@ -84,10 +84,11 @@ return [
$user = $context->getUser();
$userPageHelper = $services->getService( 'Minerva.SkinUserPageHelper' );
$languagesHelper = $services->getService( 'Minerva.LanguagesHelper' );
$namespaceInfo = $services->getNamespaceInfo();
$relevantUserPageHelper = $title->inNamespace( NS_USER_TALK ) ?
new SkinUserPageHelper(
$context->getSkin()->getRelevantTitle()->getSubjectPage()
$namespaceInfo->getSubjectPage( $context->getSkin()->getRelevantTitle() )
) :
$userPageHelper;

View file

@ -20,6 +20,7 @@
namespace MediaWiki\Minerva\Skins;
use MediaWiki\Linker\LinkTarget;
use Title;
use User;
@ -39,9 +40,9 @@ class SkinUserPageHelper {
private $pageUser;
/**
* @param Title|null $title
* @param Title|LinkTarget|null $title
*/
public function __construct( Title $title = null ) {
public function __construct( $title = null ) {
$this->title = $title;
}

View file

@ -2,6 +2,7 @@
namespace Tests\MediaWiki\Minerva;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\Minerva\Skins\SkinUserPageHelper;
use MediaWikiTestCase;
use Title;
@ -24,6 +25,20 @@ class SkinUserPageHelperTest extends MediaWikiTestCase {
$this->assertFalse( $helper->isUserPage() );
}
/**
* @covers ::isUserPage
* @covers ::getPageUser
*/
public function testLinkTargetAsConsumer() {
$linkTarget = $this->createMock( LinkTarget::class );
$linkTarget->method( 'getText' )
->willReturn( 'User:LinkTarget' );
$helper = new SkinUserPageHelper( $linkTarget );
$this->assertNull( $helper->getPageUser() );
$this->assertFalse( $helper->isUserPage() );
}
/**
* @covers ::isUserPage
* @covers ::fetchData