Merge "Minerva shouldn't call Skin::getNewTalks() twice"
This commit is contained in:
commit
7a83809f4d
|
@ -149,7 +149,7 @@ class SkinMinerva extends SkinTemplate {
|
|||
$this->prepareMenuButton( $tpl );
|
||||
$this->prepareBanners( $tpl );
|
||||
$this->preparePageActions( $tpl );
|
||||
$this->prepareUserButton( $tpl );
|
||||
$this->prepareUserButton( $tpl, $tpl->get( 'newtalk' ) );
|
||||
$this->prepareLanguages( $tpl );
|
||||
|
||||
return $tpl;
|
||||
|
@ -385,8 +385,9 @@ class SkinMinerva extends SkinTemplate {
|
|||
/**
|
||||
* Prepares the user button.
|
||||
* @param QuickTemplate $tpl
|
||||
* @param string $newTalks New talk page messages for the current user
|
||||
*/
|
||||
protected function prepareUserButton( QuickTemplate $tpl ) {
|
||||
protected function prepareUserButton( QuickTemplate $tpl, $newTalks ) {
|
||||
// Set user button to empty string by default
|
||||
$tpl->set( 'secondaryButtonData', '' );
|
||||
$notificationsTitle = '';
|
||||
|
@ -396,7 +397,6 @@ class SkinMinerva extends SkinTemplate {
|
|||
$hasUnseen = false;
|
||||
|
||||
$user = $this->getUser();
|
||||
$newtalks = $this->getNewtalks();
|
||||
$currentTitle = $this->getTitle();
|
||||
|
||||
// If Echo is available, the user is logged in, and they are not already on the
|
||||
|
@ -431,7 +431,7 @@ class SkinMinerva extends SkinTemplate {
|
|||
|
||||
$countLabel = $this->getFormattedEchoNotificationCount( $count );
|
||||
}
|
||||
} elseif ( !empty( $newtalks ) ) {
|
||||
} elseif ( !empty( $newTalks ) ) {
|
||||
$notificationsTitle = SpecialPage::getTitleFor( 'Mytalk' );
|
||||
$notificationsMsg = $this->msg( 'mobile-frontend-user-newmessages' )->text();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\MediaWiki\Minerva;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Minerva\SkinOptions;
|
||||
use MediaWikiTestCase;
|
||||
use MinervaUI;
|
||||
|
@ -202,7 +203,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
|||
$skin = TestingAccessWrapper::newFromObject(
|
||||
$this->getMockBuilder( SkinMinerva::class )
|
||||
->disableOriginalConstructor()
|
||||
->setMethods( [ 'getTitle', 'getUser', 'getNewtalks', 'useEcho',
|
||||
->setMethods( [ 'getTitle', 'getUser', 'useEcho',
|
||||
'getEchoNotifUser', 'getEchoSeenTime',
|
||||
'getFormattedEchoNotificationCount' ] )
|
||||
->getMock()
|
||||
|
@ -213,9 +214,6 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
|||
$skin->expects( $this->any() )
|
||||
->method( 'getUser' )
|
||||
->will( $this->returnValue( $user ) );
|
||||
$skin->expects( $this->any() )
|
||||
->method( 'getNewtalks' )
|
||||
->will( $this->returnValue( $newtalks ) );
|
||||
$skin->expects( $this->any() )
|
||||
->method( 'useEcho' )
|
||||
->will( $this->returnValue( $useEcho ) );
|
||||
|
@ -238,8 +236,10 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
|||
|
||||
$tpl = $this->getMockBuilder( QuickTemplate::class )
|
||||
->setMethods( [ 'execute' ] )
|
||||
->setConstructorArgs( [ MediaWikiServices::getInstance()->getMainConfig() ] )
|
||||
->getMock();
|
||||
$skin->prepareUserButton( $tpl );
|
||||
$skin->prepareUserButton( $tpl, $newtalks );
|
||||
|
||||
$this->assertEquals(
|
||||
$expectedSecondaryButtonData,
|
||||
$tpl->get( 'secondaryButtonData' ),
|
||||
|
|
Loading…
Reference in New Issue