Pass conflictsWithNavPopupsGadget to js client

Changes:
 - Pass conflictsWithNavPopupsGadget to JS via GlobalVariablesScript hook

Bug: T151058
Change-Id: I4c15296e2fa3d411561be0ef1f914c7cc9beccd2
This commit is contained in:
Piotr Miazga 2017-01-23 23:00:27 +01:00
parent 5071efcf9c
commit 84abecab2b
2 changed files with 12 additions and 4 deletions

View file

@ -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 );
}
/**

View file

@ -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' ] );
}
}