mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-29 01:44:31 +00:00
Merge "Always set the PagePreviews visibility state"
This commit is contained in:
commit
e88c639879
|
@ -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' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
] );
|
||||
|
|
Loading…
Reference in a new issue