2016-12-16 02:47:52 +00:00
|
|
|
<?php
|
2016-12-20 21:54:47 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension Popups.
|
|
|
|
*
|
|
|
|
* Popups is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Popups is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Popups. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup extensions
|
|
|
|
*/
|
2021-05-01 17:46:14 +00:00
|
|
|
|
|
|
|
use MediaWiki\User\UserOptionsManager;
|
2017-01-04 16:33:40 +00:00
|
|
|
use Popups\PopupsContext;
|
2017-02-14 19:22:55 +00:00
|
|
|
use Popups\PopupsHooks;
|
2019-10-10 15:15:31 +00:00
|
|
|
use Psr\Log\LoggerInterface;
|
2016-12-16 02:47:52 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-20 20:20:43 +00:00
|
|
|
* Integration tests for popups hooks
|
2016-12-16 02:47:52 +00:00
|
|
|
*
|
|
|
|
* @group Popups
|
2017-12-27 19:53:07 +00:00
|
|
|
* @coversDefaultClass \Popups\PopupsHooks
|
2016-12-16 02:47:52 +00:00
|
|
|
*/
|
2021-10-11 23:00:04 +00:00
|
|
|
class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
2016-12-16 02:47:52 +00:00
|
|
|
|
|
|
|
/**
|
2016-12-20 21:54:47 +00:00
|
|
|
* @covers ::onGetPreferences
|
2016-12-16 02:47:52 +00:00
|
|
|
*/
|
|
|
|
public function testOnGetPreferencesPreviewsDisabled() {
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2016-12-16 02:47:52 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( false );
|
2016-12-16 02:47:52 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2016-12-16 02:47:52 +00:00
|
|
|
$prefs = [ 'someNotEmptyValue' => 'notEmpty' ];
|
|
|
|
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
2018-05-08 19:48:17 +00:00
|
|
|
$this->assertCount( 1, $prefs, 'No preferences are retrieved.' );
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertSame( 'notEmpty',
|
2018-05-08 19:48:17 +00:00
|
|
|
$prefs[ 'someNotEmptyValue'],
|
|
|
|
'No preferences are changed.' );
|
2016-12-16 02:47:52 +00:00
|
|
|
}
|
|
|
|
|
2017-01-04 16:33:40 +00:00
|
|
|
/**
|
|
|
|
* @covers ::onGetPreferences
|
|
|
|
*/
|
|
|
|
public function testOnGetPreferencesNavPopupGadgetIsOn() {
|
|
|
|
$userMock = $this->getTestUser()->getUser();
|
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2017-01-04 16:33:40 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( true );
|
2017-01-04 16:33:40 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'conflictsWithNavPopupsGadget' )
|
|
|
|
->with( $userMock )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( true );
|
2017-01-04 16:33:40 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2017-01-04 16:33:40 +00:00
|
|
|
$prefs = [];
|
|
|
|
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
2018-05-08 19:48:17 +00:00
|
|
|
$this->assertArrayHasKey( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
|
|
|
$prefs,
|
|
|
|
'The opt-in preference is retrieved.' );
|
2017-01-04 16:33:40 +00:00
|
|
|
$this->assertArrayHasKey( 'disabled',
|
2018-05-08 19:48:17 +00:00
|
|
|
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ],
|
|
|
|
'The opt-in preference has a status.' );
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertTrue(
|
2018-05-08 19:48:17 +00:00
|
|
|
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['disabled'],
|
2019-03-01 10:28:20 +00:00
|
|
|
'The opt-in preference\'s status is disabled.' );
|
2018-05-08 19:48:17 +00:00
|
|
|
$this->assertNotEmpty( $prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['help-message'],
|
|
|
|
'The opt-in preference has a help message.' );
|
2017-01-04 16:33:40 +00:00
|
|
|
}
|
|
|
|
|
2016-12-16 02:47:52 +00:00
|
|
|
/**
|
2016-12-20 21:54:47 +00:00
|
|
|
* @covers ::onGetPreferences
|
2016-12-16 02:47:52 +00:00
|
|
|
*/
|
|
|
|
public function testOnGetPreferencesPreviewsEnabled() {
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2016-12-16 02:47:52 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( true );
|
2017-01-11 21:52:07 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'conflictsWithNavPopupsGadget' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( false );
|
2016-12-16 02:47:52 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2016-12-20 22:49:01 +00:00
|
|
|
$prefs = [
|
|
|
|
'skin' => 'skin stuff',
|
|
|
|
'someNotEmptyValue' => 'notEmpty',
|
|
|
|
'other' => 'notEmpty'
|
|
|
|
];
|
2016-12-16 02:47:52 +00:00
|
|
|
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
2019-10-10 14:24:51 +00:00
|
|
|
$this->assertGreaterThan( 3, count( $prefs ), 'A preference is retrieved.' );
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertSame( 'notEmpty',
|
2018-05-08 19:48:17 +00:00
|
|
|
$prefs[ 'someNotEmptyValue'],
|
|
|
|
'Unretrieved preferences are unchanged.' );
|
|
|
|
$this->assertArrayHasKey( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
|
|
|
$prefs,
|
|
|
|
'The opt-in preference is retrieved.' );
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertSame( 1,
|
2019-10-10 15:15:31 +00:00
|
|
|
array_search( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
2018-05-08 19:48:17 +00:00
|
|
|
array_keys( $prefs ) ),
|
|
|
|
'The opt-in preference is injected after Skin select.' );
|
2016-12-20 22:49:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::onGetPreferences
|
|
|
|
*/
|
|
|
|
public function testOnGetPreferencesPreviewsEnabledWhenSkinIsNotAvailable() {
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2016-12-20 22:49:01 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( true );
|
2017-01-11 21:52:07 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'conflictsWithNavPopupsGadget' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( false );
|
2016-12-20 22:49:01 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2016-12-20 22:49:01 +00:00
|
|
|
$prefs = [
|
|
|
|
'someNotEmptyValue' => 'notEmpty',
|
|
|
|
'other' => 'notEmpty'
|
|
|
|
];
|
|
|
|
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onGetPreferences( $this->getTestUser()->getUser(), $prefs );
|
2019-10-10 14:24:51 +00:00
|
|
|
$this->assertGreaterThan( 2, count( $prefs ), 'A preference is retrieved.' );
|
2018-05-08 19:48:17 +00:00
|
|
|
$this->assertArrayHasKey( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
|
|
|
$prefs,
|
|
|
|
'The opt-in preference is retrieved.' );
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertSame( 2,
|
2018-05-08 19:48:17 +00:00
|
|
|
array_search( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME,
|
|
|
|
array_keys( $prefs ) ),
|
|
|
|
'The opt-in preference is appended.' );
|
2016-12-16 02:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-20 21:54:47 +00:00
|
|
|
* @covers ::onResourceLoaderGetConfigVars
|
2016-12-16 02:47:52 +00:00
|
|
|
*/
|
|
|
|
public function testOnResourceLoaderGetConfigVars() {
|
|
|
|
$vars = [ 'something' => 'notEmpty' ];
|
2017-01-15 18:59:37 +00:00
|
|
|
$config = [
|
2018-03-07 20:15:30 +00:00
|
|
|
'wgPopupsRestGatewayEndpoint' => '/api',
|
2018-02-08 22:11:44 +00:00
|
|
|
'wgPopupsVirtualPageViews' => true,
|
2017-06-08 13:29:57 +00:00
|
|
|
'wgPopupsGateway' => 'mwApiPlain',
|
2020-11-26 13:09:57 +00:00
|
|
|
'wgPopupsStatsvSamplingRate' => 0,
|
|
|
|
'wgPopupsTextExtractsIntroOnly' => true,
|
2017-01-15 18:59:37 +00:00
|
|
|
];
|
|
|
|
$this->setMwGlobals( $config );
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onResourceLoaderGetConfigVars( $vars, '', new MultiConfig( $config ) );
|
2021-03-02 17:08:45 +00:00
|
|
|
$this->assertCount( 6, $vars, 'A configuration is retrieved.' );
|
2017-01-15 18:59:37 +00:00
|
|
|
|
|
|
|
foreach ( $config as $key => $value ) {
|
2019-10-04 08:31:58 +00:00
|
|
|
$this->assertSame(
|
2017-01-15 18:59:37 +00:00
|
|
|
$value,
|
|
|
|
$vars[ $key ],
|
|
|
|
"It forwards the \"{$key}\" config variable to the client."
|
|
|
|
);
|
|
|
|
}
|
2016-12-16 02:47:52 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 21:54:47 +00:00
|
|
|
/**
|
|
|
|
* @covers ::onBeforePageDisplay
|
|
|
|
*/
|
|
|
|
public function testOnBeforePageDisplayWhenDependenciesAreNotMet() {
|
2019-10-06 05:43:20 +00:00
|
|
|
$skinMock = $this->createMock( Skin::class );
|
2019-10-10 15:15:31 +00:00
|
|
|
$outPageMock = $this->createMock( OutputPage::class );
|
2016-12-20 21:54:47 +00:00
|
|
|
$outPageMock->expects( $this->never() )
|
|
|
|
->method( 'addModules' );
|
2019-10-10 15:15:31 +00:00
|
|
|
$loggerMock = $this->createMock( LoggerInterface::class );
|
2016-12-20 21:54:47 +00:00
|
|
|
$loggerMock->expects( $this->once() )
|
|
|
|
->method( 'error' );
|
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2016-12-20 21:54:47 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'areDependenciesMet' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( false );
|
2017-07-28 18:58:13 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
2020-06-09 06:52:42 +00:00
|
|
|
->method( 'isTitleExcluded' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( false );
|
2016-12-20 21:54:47 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'getLogger' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( $loggerMock );
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onBeforePageDisplay( $outPageMock, $skinMock );
|
2016-12-20 21:54:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 22:08:12 +00:00
|
|
|
public function providerOnBeforePageDisplay() {
|
|
|
|
return [
|
2018-04-26 20:43:05 +00:00
|
|
|
[ false, false, false ],
|
|
|
|
[ true, true, false ],
|
2020-06-09 06:52:42 +00:00
|
|
|
// Code not sent if title is excluded
|
2018-04-26 20:43:05 +00:00
|
|
|
[ true, false, true ],
|
2020-06-09 06:52:42 +00:00
|
|
|
// Code not sent if title is excluded
|
2018-04-26 20:43:05 +00:00
|
|
|
[ false, false, true ]
|
2017-02-08 22:08:12 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:54:47 +00:00
|
|
|
/**
|
|
|
|
* @covers ::onBeforePageDisplay
|
2017-02-08 22:08:12 +00:00
|
|
|
* @dataProvider providerOnBeforePageDisplay
|
2016-12-20 21:54:47 +00:00
|
|
|
*/
|
2017-05-16 17:59:29 +00:00
|
|
|
public function testOnBeforePageDisplay( $shouldSendModuleToUser,
|
2020-06-09 06:52:42 +00:00
|
|
|
$isCodeLoaded, $isTitleExcluded ) {
|
2019-10-06 05:43:20 +00:00
|
|
|
$skinMock = $this->createMock( Skin::class );
|
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$outPageMock = $this->createMock( OutputPage::class );
|
2017-02-08 22:08:12 +00:00
|
|
|
$outPageMock->expects( $isCodeLoaded ? $this->once() : $this->never() )
|
2016-12-21 12:35:35 +00:00
|
|
|
->method( 'addModules' )
|
|
|
|
->with( [ 'ext.popups' ] );
|
2019-10-10 15:15:31 +00:00
|
|
|
$outPageMock->method( 'getUser' )
|
|
|
|
->willReturn( User::newFromId( 0 ) );
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2017-02-08 22:08:12 +00:00
|
|
|
|
2020-06-09 06:52:42 +00:00
|
|
|
if ( !$isTitleExcluded ) {
|
2017-07-28 18:58:13 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
|
|
|
->method( 'areDependenciesMet' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( true );
|
2017-07-28 18:58:13 +00:00
|
|
|
}
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2022-09-29 12:41:35 +00:00
|
|
|
$contextMock->method( 'shouldSendModuleToUser' )
|
|
|
|
->willReturn( $shouldSendModuleToUser );
|
2017-02-08 22:08:12 +00:00
|
|
|
|
2017-07-28 18:58:13 +00:00
|
|
|
$contextMock->expects( $this->once() )
|
2020-06-09 06:52:42 +00:00
|
|
|
->method( 'isTitleExcluded' )
|
2022-09-29 12:41:35 +00:00
|
|
|
->willReturn( $isTitleExcluded );
|
2017-07-28 18:58:13 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onBeforePageDisplay( $outPageMock, $skinMock );
|
2016-12-20 21:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-27 19:53:07 +00:00
|
|
|
* @covers ::onMakeGlobalVariablesScript
|
2016-12-20 21:54:47 +00:00
|
|
|
*/
|
2016-12-21 12:35:35 +00:00
|
|
|
public function testOnMakeGlobalVariablesScript() {
|
|
|
|
$user = User::newFromId( 0 );
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$outputPage = $this->createMock( OutputPage::class );
|
2022-09-29 12:41:35 +00:00
|
|
|
$outputPage->method( 'getUser' )
|
2016-12-21 12:35:35 +00:00
|
|
|
->willReturn( $user );
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$contextMock = $this->createMock( PopupsContext::class );
|
2022-09-29 12:41:35 +00:00
|
|
|
$contextMock->method( 'getConfigBitmaskFromUser' )
|
2019-10-10 14:24:51 +00:00
|
|
|
->with( $user )
|
2021-03-09 17:21:48 +00:00
|
|
|
->willReturn( 0 );
|
2016-12-20 21:54:47 +00:00
|
|
|
|
2017-07-21 17:06:08 +00:00
|
|
|
$this->setService( 'Popups.Context', $contextMock );
|
2016-12-21 12:35:35 +00:00
|
|
|
|
|
|
|
$vars = [];
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onMakeGlobalVariablesScript( $vars, $outputPage );
|
2016-12-21 12:35:35 +00:00
|
|
|
|
2021-03-09 17:21:48 +00:00
|
|
|
$this->assertCount( 1, $vars, 'Number of added variables.' );
|
|
|
|
$this->assertSame( 0, $vars[ 'wgPopupsFlags' ],
|
|
|
|
'The wgPopupsFlags global is present and 0.' );
|
2016-12-20 21:54:47 +00:00
|
|
|
}
|
2018-05-09 21:21:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::onUserGetDefaultOptions
|
2021-03-19 11:23:40 +00:00
|
|
|
* @dataProvider provideReferencePreviewsBetaFlag
|
2018-05-09 21:21:30 +00:00
|
|
|
*/
|
2021-03-19 11:23:40 +00:00
|
|
|
public function testOnUserGetDefaultOptions( $beta ) {
|
2018-05-09 21:21:30 +00:00
|
|
|
$userOptions = [
|
|
|
|
'test' => 'not_empty'
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->setMwGlobals( [
|
2019-12-17 10:58:36 +00:00
|
|
|
'wgPopupsOptInDefaultState' => '1',
|
|
|
|
'wgPopupsReferencePreviews' => true,
|
2021-03-19 11:23:40 +00:00
|
|
|
'wgPopupsReferencePreviewsBetaFeature' => $beta,
|
2018-05-09 21:21:30 +00:00
|
|
|
] );
|
|
|
|
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onUserGetDefaultOptions( $userOptions );
|
2021-03-19 11:23:40 +00:00
|
|
|
$this->assertCount( 3 - $beta, $userOptions );
|
|
|
|
$this->assertSame( '1', $userOptions[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
|
|
|
|
if ( $beta === false ) {
|
2021-04-27 11:09:31 +00:00
|
|
|
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA ] );
|
2021-03-19 11:23:40 +00:00
|
|
|
}
|
2018-05-09 21:21:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::onUserGetDefaultOptions
|
2021-03-19 11:23:40 +00:00
|
|
|
* @dataProvider provideReferencePreviewsBetaFlag
|
2018-05-09 21:21:30 +00:00
|
|
|
*/
|
2021-03-19 11:23:40 +00:00
|
|
|
public function testOnLocalUserCreatedForNewlyCreatedUser( $beta ) {
|
2018-05-09 21:21:30 +00:00
|
|
|
$expectedState = '1';
|
|
|
|
|
2019-10-10 15:15:31 +00:00
|
|
|
$userMock = $this->createMock( User::class );
|
2021-05-01 17:46:14 +00:00
|
|
|
|
|
|
|
$userOptionsManagerMock = $this->createMock( UserOptionsManager::class );
|
|
|
|
$userOptionsManagerMock->expects( $this->exactly( 2 - $beta ) )
|
2018-05-09 21:21:30 +00:00
|
|
|
->method( 'setOption' )
|
2019-12-17 10:58:36 +00:00
|
|
|
->withConsecutive(
|
2021-05-01 17:46:14 +00:00
|
|
|
[ $userMock, 'popups', $expectedState ],
|
|
|
|
[ $userMock, 'popups-reference-previews', $expectedState ]
|
2019-12-17 10:58:36 +00:00
|
|
|
);
|
2021-05-01 17:46:14 +00:00
|
|
|
$this->setService( 'UserOptionsManager', $userOptionsManagerMock );
|
2018-05-09 21:21:30 +00:00
|
|
|
|
|
|
|
$this->setMwGlobals( [
|
2019-12-17 10:58:36 +00:00
|
|
|
'wgPopupsOptInStateForNewAccounts' => $expectedState,
|
|
|
|
'wgPopupsReferencePreviews' => true,
|
2021-03-19 11:23:40 +00:00
|
|
|
'wgPopupsReferencePreviewsBetaFeature' => $beta,
|
2018-05-09 21:21:30 +00:00
|
|
|
] );
|
2021-11-29 13:50:08 +00:00
|
|
|
( new PopupsHooks() )->onLocalUserCreated( $userMock, false );
|
2018-05-09 21:21:30 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 11:23:40 +00:00
|
|
|
public function provideReferencePreviewsBetaFlag() {
|
|
|
|
return [
|
|
|
|
[ false ],
|
|
|
|
[ true ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-12-16 02:47:52 +00:00
|
|
|
}
|