jenkins-bot has submitted this change and it was merged.

Change subject: Revert "Make NoLangLinkHandler testable."
......................................................................


Revert "Make NoLangLinkHandler testable."

This reverts commit cd9e0c26f3dc2c1677a4d9b55311c694747dd10a.

probably is something easy to fix, but this is the culprit.

best to revert for now and then reapply/fix.

Bug: T86886
Change-Id: Ibf6258dc86dc9d244871fbecac2bf41c3c569bcf
---
M client/includes/parserhooks/NoLangLinkHandler.php
D client/tests/phpunit/includes/hooks/NoLangLinkHandlerTest.php
2 files changed, 11 insertions(+), 86 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/client/includes/parserhooks/NoLangLinkHandler.php 
b/client/includes/parserhooks/NoLangLinkHandler.php
index ef5e1bc..71619dd 100644
--- a/client/includes/parserhooks/NoLangLinkHandler.php
+++ b/client/includes/parserhooks/NoLangLinkHandler.php
@@ -19,41 +19,6 @@
 class NoLangLinkHandler {
 
        /**
-        * @var NamespaceChecker
-        */
-       private $namespaceChecker;
-
-       /**
-        * Parser function
-        *
-        * @since 0.4
-        *
-        * @param \Parser &$parser
-        *
-        * @return string
-        */
-       public static function handle( &$parser ) {
-               $handler = self::newFromGlobalState();
-               $handler->doHandle( $parser );
-       }
-
-       private static function newFromGlobalState() {
-               $wikibaseClient = WikibaseClient::getDefaultInstance();
-               $settings = $wikibaseClient->getSettings();
-
-               $namespaceChecker = new NamespaceChecker(
-                       $settings->getSetting( 'excludeNamespaces' ),
-                       $settings->getSetting( 'namespaces' )
-               );
-
-               return new NoLangLinkHandler( $namespaceChecker );
-       }
-
-       public function __construct( NamespaceChecker $namespaceChecker ) {
-               $this->namespaceChecker = $namespaceChecker;
-       }
-
-       /**
         * Get the noexternallanglinks page property from the ParserOutput,
         * which is set by the {{#noexternallanglinks}} parser function.
         *
@@ -84,15 +49,22 @@
        /**
         * Parser function
         *
-        * @since 0.5
+        * @since 0.4
         *
         * @param \Parser &$parser
         *
         * @return string
         */
-       public function doHandle( &$parser ) {
+       public static function handle( &$parser ) {
+               $wikibaseClient = WikibaseClient::getDefaultInstance();
+               $settings = $wikibaseClient->getSettings();
 
-               if ( !$this->namespaceChecker->isWikibaseEnabled( 
$parser->getTitle()->getNamespace() ) ) {
+               $namespaceChecker = new NamespaceChecker(
+                       $settings->getSetting( 'excludeNamespaces' ),
+                       $settings->getSetting( 'namespaces' )
+               );
+
+               if ( !$namespaceChecker->isWikibaseEnabled( 
$parser->getTitle()->getNamespace() ) ) {
                        // shorten out
                        return '';
                }
@@ -104,7 +76,7 @@
                $output = $parser->getOutput();
 
                $nel = array_merge( self::getNoExternalLangLinks( $output ), 
$langs );
-               $this->setNoExternalLangLinks( $output, $nel );
+               self::setNoExternalLangLinks( $output, $nel );
 
                return '';
        }
diff --git a/client/tests/phpunit/includes/hooks/NoLangLinkHandlerTest.php 
b/client/tests/phpunit/includes/hooks/NoLangLinkHandlerTest.php
deleted file mode 100644
index 973fa94..0000000
--- a/client/tests/phpunit/includes/hooks/NoLangLinkHandlerTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-namespace Wikibase\Client\Tests\Hooks;
-
-use Parser;
-use ParserOptions;
-use ParserOutput;
-use Wikibase\NamespaceChecker;
-use Wikibase\NoLangLinkHandler;
-
-/**
- * @covers Wikibase\NoLangLinkHandler
- *
- * @group WikibaseClient
- * @group HookHandler
- * @group Wikibase
- *
- * @licence GNU GPL v2+
- * @author Daniel Kinzler
- */
-class NoLangLinkHandlerTest extends \PHPUnit_Framework_TestCase {
-
-       public function testGetSetNoExternalLangLinks() {
-               $pout = new ParserOutput();
-               $list = array( 'xy', 'abc' );
-
-               NoLangLinkHandler::setNoExternalLangLinks( $pout, $list );
-               $actual = NoLangLinkHandler::getNoExternalLangLinks( $pout );
-
-               $this->assertEquals( $list, $actual );
-       }
-
-       public function testDoHandle() {
-               $handler = new NoLangLinkHandler( new NamespaceChecker( 
array(), array() ) );
-               $parser = new Parser();
-               $parser->startExternalParse( null, new ParserOptions(), 
Parser::OT_HTML );
-
-               $handler->doHandle( $parser, 'en', 'fr' );
-               $actual = NoLangLinkHandler::getNoExternalLangLinks( 
$parser->getOutput() );
-               $this->assertEquals( array( 'en', 'fr' ), $actual );
-
-               $handler->doHandle( $parser, '*', 'zh' );
-               $actual = NoLangLinkHandler::getNoExternalLangLinks( 
$parser->getOutput() );
-               $this->assertEquals( array( 'en', 'fr', '*', 'zh' ), $actual );
-       }
-
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/185136
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf6258dc86dc9d244871fbecac2bf41c3c569bcf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.25wmf14
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to