jenkins-bot has submitted this change and it was merged.
Change subject: Fix AskParserFunction name/class
......................................................................
Fix AskParserFunction name/class
No logic or process change.
Change-Id: I5a69a72cf4261001cfc7b70bd5151c8a475b227a
---
M SemanticMediaWiki.hooks.php
M includes/Setup.php
M includes/parserhooks/AskParserFunction.php
A tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
4 files changed, 75 insertions(+), 18 deletions(-)
Approvals:
Mwjames: Looks good to me, approved
jenkins-bot: Verified
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index 2677985..80adb27 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -125,7 +125,7 @@
* @return boolean
*/
public static function onParserFirstCallInit( Parser &$parser ) {
- $parser->setFunctionHook( 'ask', array( 'SMWAsk', 'render' ) );
+ $parser->setFunctionHook( 'ask', array(
'SMW\AskParserFunction', 'render' ) );
$parser->setFunctionHook( 'show', array( 'SMWShow', 'render' )
);
$parser->setFunctionHook( 'subobject', array(
'SMW\SubobjectParserFunction', 'render' ) );
$parser->setFunctionHook( 'concept', array( 'SMWConcept',
'render' ) );
@@ -287,6 +287,7 @@
'parserhooks/SubobjectParserFunction',
'parserhooks/RecurringEvents',
'parserhooks/RecurringEventsParserFunction',
+ 'parserhooks/AskParserFunctionTest',
'printers/ResultPrinters',
diff --git a/includes/Setup.php b/includes/Setup.php
index dae8de1..b726a5f 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -201,7 +201,7 @@
// Parser hooks
$phDir = $smwgIP . 'includes/parserhooks/';
- $wgAutoloadClasses['SMWAsk'] = $phDir .
'AskParserFunction.php';
+ $wgAutoloadClasses['SMW\AskParserFunction'] = $phDir .
'AskParserFunction.php';
$wgAutoloadClasses['SMWShow'] = $phDir .
'ShowParserFunction.php';
$wgAutoloadClasses['SMWInfo'] = $phDir .
'SMW_Info.php';
$wgAutoloadClasses['SMWConcept'] = $phDir .
'ConceptParserFunction.php';
diff --git a/includes/parserhooks/AskParserFunction.php
b/includes/parserhooks/AskParserFunction.php
index 1c7372c..95f5be0 100644
--- a/includes/parserhooks/AskParserFunction.php
+++ b/includes/parserhooks/AskParserFunction.php
@@ -1,4 +1,11 @@
<?php
+
+namespace SMW;
+
+use Parser;
+use SMWQueryProcessor;
+use SMWOutputs;
+
/**
* @file
* @since 1.5.3
@@ -17,7 +24,7 @@
* @author Markus Krötzsch
* @author Jeroen De Dauw
*/
-class SMWAsk {
+class AskParserFunction {
/**
* Method for handling the ask parser function.
@@ -69,38 +76,38 @@
*
* @since 1.8
*/
- public static function addQueryData( $queryKey, SMWQuery $query, array
$params, Parser $parser ) {
- $mainSemanticData = SMWParseData::getSMWData( $parser );
+ public static function addQueryData( $queryKey, \SMWQuery $query, array
$params, Parser $parser ) {
+ $mainSemanticData = \SMWParseData::getSMWData( $parser );
$subject = $mainSemanticData->getSubject();
- $diSubWikiPage = new SMWDIWikiPage( $subject->getDBkey(),
+ $diSubWikiPage = new \SMWDIWikiPage( $subject->getDBkey(),
$subject->getNamespace(),
$subject->getInterwiki(),
"_QUERY" . $queryKey );
- $semanticData = new SMWContainerSemanticData( $diSubWikiPage );
+ $semanticData = new \SMWContainerSemanticData( $diSubWikiPage );
$description = $query->getDescription();
// Add query string
- $propertyDi = new SMWDIProperty( '_ASKST' );
- $valueDi = new SMWDIBlob( $description->getQueryString() );
+ $propertyDi = new \SMWDIProperty( '_ASKST' );
+ $valueDi = new \SMWDIBlob( $description->getQueryString() );
$semanticData->addPropertyObjectValue( $propertyDi, $valueDi );
// Add query size
- $propertyDi = new SMWDIProperty( '_ASKSI' );
- $valueDi = new SMWDINumber( $description->getSize() );
+ $propertyDi = new \SMWDIProperty( '_ASKSI' );
+ $valueDi = new \SMWDINumber( $description->getSize() );
$semanticData->addPropertyObjectValue( $propertyDi, $valueDi );
// Add query depth
- $propertyDi = new SMWDIProperty( '_ASKDE' );
- $valueDi = new SMWDINumber( $description->getDepth() );
+ $propertyDi = new \SMWDIProperty( '_ASKDE' );
+ $valueDi = new \SMWDINumber( $description->getDepth() );
$semanticData->addPropertyObjectValue( $propertyDi, $valueDi );
// Add query format
- $propertyDi = new SMWDIProperty( '_ASKFO' );
- $valueDi = new SMWDIBlob( $params['format']->getValue() );
+ $propertyDi = new \SMWDIProperty( '_ASKFO' );
+ $valueDi = new \SMWDIBlob( $params['format']->getValue() );
$semanticData->addPropertyObjectValue( $propertyDi, $valueDi );
- $propertyDi = new SMWDIProperty( '_ASK' );
- $subObjectDi = new SMWDIContainer( $semanticData );
- SMWParseData::getSMWData( $parser )->addPropertyObjectValue(
$propertyDi, $subObjectDi );
+ $propertyDi = new \SMWDIProperty( '_ASK' );
+ $subObjectDi = new \SMWDIContainer( $semanticData );
+ \SMWParseData::getSMWData( $parser )->addPropertyObjectValue(
$propertyDi, $subObjectDi );
}
}
diff --git a/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
b/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
new file mode 100644
index 0000000..fb318ea
--- /dev/null
+++ b/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\AskParserFunction;
+
+/**
+ * Tests for the SMW\AskParserFunction class.
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 1.9
+ *
+ * @ingroup SMW
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @licence GNU GPL v2+
+ * @author mwjames
+ */
+class AskParserFunctionTest extends \MediaWikiTestCase {
+
+ // Will be extended in a follow-up
+
+ /**
+ * Test instance
+ *
+ */
+ public function testConstructor() {
+ $instance = new AskParserFunction();
+ $this->assertInstanceOf( 'SMW\AskParserFunction', $instance );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/56785
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5a69a72cf4261001cfc7b70bd5151c8a475b227a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits