Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/359226 )
Change subject: MobileFrontend is removing the disabled images feature ...................................................................... MobileFrontend is removing the disabled images feature Thus do not call this. Bug: T109870 Change-Id: I88fc77d6a443dc1713ef50f20a21cfbe29d532e4 --- M includes/WikidataPageBanner.hooks.php D tests/phpunit/BannerMFTest.php 2 files changed, 0 insertions(+), 112 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/26/359226/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index baaf837..9e065c9 100755 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -75,14 +75,6 @@ * @return bool */ public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { - // if images are disabled on Minerva skin, then do nothing - if ( class_exists( MobileContext::class ) - && MobileContext::singleton()->shouldDisplayMobileView() - && MobileContext::singleton()->imagesDisabled() === true - ) { - return true; - } - $config = WikidataPageBannerFunctions::getWPBConfig(); $title = $out->getTitle(); $isDiff = $out->getRequest()->getCheck( 'diff' ); diff --git a/tests/phpunit/BannerMFTest.php b/tests/phpunit/BannerMFTest.php deleted file mode 100644 index 031c5e1..0000000 --- a/tests/phpunit/BannerMFTest.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * @group WikidataPageBanner - */ - -/** - * Test for checking compatibility with imagesDisabled option in MobileFrontendExtension - */ -class BannerMFTest extends MediaWikiTestCase { - /** - * Stores the original value for MobileContext - * @var MobileContext|null - */ - private static $oldMobileContext; - - /** - * Add test pages to database - * @see MediaWikiTestCase::addDBData() - */ - public function addDBData() { - try { - if ( !Title::newFromText( 'PageWithoutCustomBanner', NS_MAIN )->exists() ) { - $this->insertPage( 'PageWithoutCustomBanner', 'Some Text' ); - } - } catch ( Exception $e ) { - } - } - - protected function setUp() { - parent::setUp(); - - if ( class_exists( MobileContext::class ) ) { - self::$oldMobileContext = MobileContext::singleton(); - $mobileContext = $this->makeContext(); - $mobileContext->setForceMobileView( true ); - MobileContext::setInstance( $mobileContext ); - // set protected disableImages property to true, so that we can simulate images disabled - $reflectionClass = new ReflectionClass( 'MobileContext' ); - $reflectionProperty = $reflectionClass->getProperty( 'disableImages' ); - $reflectionProperty->setAccessible( true ); - $reflectionProperty->setValue( $mobileContext, true ); - } - - $this->addDBData(); - $this->setMwGlobals( 'wgWPBImage', "DefaultBanner" ); - $this->setMwGlobals( 'wgWPBEnableDefaultBanner', true ); - } - - protected function tearDown() { - if ( class_exists( MobileContext::class ) ) { - // restore old mobile context class - MobileContext::setInstance( self::$oldMobileContext ); - } - - parent::tearDown(); - } - - /** - * Test banner addition on disabling images in MobileFrontend - */ - public function testMFBannerWithImageDisabled() { - if ( class_exists( MobileContext::class ) ) { - $skin = $this->getMock( Skin::class ); - $out = $this->createPage( 'PageWithoutCustomBanner', NS_MAIN ); - WikidataPageBanner::onBeforePageDisplay( $out, $skin ); - $this->assertNull( $out->getProperty( 'articlebanner-name' ) ); - } - } - - /** - * Helper function for testDefaultBanner - * @param string $title - * @param int $namespace - * @return OutputPage - */ - protected function createPage( $title, $namespace ) { - $context = new RequestContext(); - $curTitle = Title::newFromText( $title, $namespace ); - $context->setTitle( $curTitle ); - $out = $context->getOutput(); - $out->setTitle( $curTitle ); - $out->setPageTitle( $title ); - $out->setArticleFlag( true ); - return $out; - } - - /** - * @param string $url - * @param array $cookies - * @return MobileContext - */ - private function makeContext( $url = '/', $cookies = [] ) { - $request = new FauxRequest( [] ); - $request->setRequestURL( $url ); - $request->setCookies( $cookies, '' ); - - $context = new DerivativeContext( RequestContext::getMain() ); - $context->setRequest( $request ); - $context->setOutput( new OutputPage( $context ) ); - $instance = unserialize( 'O:13:"MobileContext":0:{}' ); - $instance->setContext( $context ); - return $instance; - } -} -- To view, visit https://gerrit.wikimedia.org/r/359226 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I88fc77d6a443dc1713ef50f20a21cfbe29d532e4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits