mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-24 10:49:14 +00:00
Pass conflictsWithNavPopupsGadget to js client
Changes: - Pass conflictsWithNavPopupsGadget to JS via GlobalVariablesScript hook Bug: T151058 Change-Id: I4c15296e2fa3d411561be0ef1f914c7cc9beccd2
This commit is contained in:
parent
5071efcf9c
commit
84abecab2b
|
@ -150,8 +150,9 @@ class PopupsHooks {
|
|||
*
|
||||
* Variables added:
|
||||
* * `wgPopupsIsEnabledByUser' - The server's notion of whether or not the
|
||||
* user has enabled Page Previews (see
|
||||
* `\Popups\PopupsContext#isEnabledByUser`).
|
||||
* user has enabled Page Previews (see `\Popups\PopupsContext#isEnabledByUser`).
|
||||
* * `wgPopupsConflictsWithNavPopupGadget' - The server's notion of whether or not the
|
||||
* user has enabled conflicting Navigational Popups Gadget.
|
||||
*
|
||||
* @param array $vars
|
||||
* @param OutputPage $out
|
||||
|
@ -161,6 +162,8 @@ class PopupsHooks {
|
|||
$user = $out->getUser();
|
||||
|
||||
$vars['wgPopupsIsEnabledByUser'] = $module->isEnabledByUser( $user );
|
||||
$vars['wgPopupsConflictsWithNavPopupGadget'] = $module->conflictsWithNavPopupsGadget(
|
||||
$user );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -300,13 +300,17 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
->willReturn( $user );
|
||||
|
||||
$contextMock = $this->getMockBuilder( PopupsContextTestWrapper::class )
|
||||
->setMethods( [ 'isEnabledByUser' ] )
|
||||
->setMethods( [ 'isEnabledByUser', 'conflictsWithNavPopupsGadget' ] )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'isEnabledByUser' )
|
||||
->with( $user )
|
||||
->willReturn( false );
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'conflictsWithNavPopupsGadget' )
|
||||
->with( $user )
|
||||
->willReturn( false );
|
||||
|
||||
PopupsContextTestWrapper::injectTestInstance( $contextMock );
|
||||
|
||||
|
@ -314,7 +318,8 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
|
||||
PopupsHooks::onMakeGlobalVariablesScript( $vars, $outputPage );
|
||||
|
||||
$this->assertCount( 1, $vars );
|
||||
$this->assertCount( 2, $vars );
|
||||
$this->assertFalse( $vars[ 'wgPopupsIsEnabledByUser' ] );
|
||||
$this->assertFalse( $vars[ 'wgPopupsConflictsWithNavPopupGadget' ] );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue