Merge "Always set the PagePreviews visibility state"

This commit is contained in:
jenkins-bot 2018-06-11 21:54:58 +00:00 committed by Gerrit Code Review
commit e88c639879
2 changed files with 5 additions and 26 deletions

View file

@ -152,12 +152,10 @@ class PopupsHooks {
* @param bool $autocreated Is user autocreated
*/
public static function onLocalUserCreated( User $user, $autocreated ) {
if ( !$autocreated ) {
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
// ignore the $autocreated flag, we always want to set PagePreviews visibility
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
$user->setOption( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
$config->get( 'PopupsOptInStateForNewAccounts' ) );
$user->saveSettings();
}
$user->setOption( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
$config->get( 'PopupsOptInStateForNewAccounts' ) );
}
}

View file

@ -329,22 +329,6 @@ class PopupsHooksTest extends MediaWikiTestCase {
$userOptions[ \Popups\PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
}
/**
* @covers ::onUserGetDefaultOptions
*/
public function testOnLocalUserCreatedForAutoCreatedUser() {
$userMock =
$this->getMockBuilder( User::class )
->disableOriginalConstructor()
->setMethods( [ 'setOption', 'saveSettings' ] )
->getMock();
$userMock->expects( $this->never() )->method( 'setOption' );
$userMock->expects( $this->never() )->method( 'saveSettings' );
PopupsHooks::onLocalUserCreated( $userMock, true );
}
/**
* @covers ::onUserGetDefaultOptions
*/
@ -353,7 +337,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
$userMock = $this->getMockBuilder( User::class )
->disableOriginalConstructor()
->setMethods( [ 'setOption', 'saveSettings' ] )
->setMethods( [ 'setOption' ] )
->getMock();
$userMock->expects( $this->once() )
->method( 'setOption' )
@ -362,9 +346,6 @@ class PopupsHooksTest extends MediaWikiTestCase {
$this->equalTo( $expectedState )
);
$userMock->expects( $this->once() )
->method( 'saveSettings' );
$this->setMwGlobals( [
'wgPopupsOptInStateForNewAccounts' => $expectedState
] );