mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-28 08:00:32 +00:00
Merge "ServiceWiring: Avoid usage of deprecated Title::getSubjectPage()"
This commit is contained in:
commit
e9b23132c3
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue