Mwjames has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83136


Change subject: Remove IParserData interface
......................................................................

Remove IParserData interface

Change-Id: Ibb3245485a188e37463552522f3b6d58449ecfca
---
M SemanticMediaWiki.classes.php
M includes/ParserData.php
M includes/ParserTextProcessor.php
M includes/parserhooks/AskParserFunction.php
M includes/parserhooks/ConceptParserFunction.php
M includes/parserhooks/RecurringEventsParserFunction.php
M includes/parserhooks/SetParserFunction.php
M includes/parserhooks/ShowParserFunction.php
M includes/parserhooks/SubobjectParserFunction.php
M tests/phpunit/ParserTestCase.php
M tests/phpunit/includes/BasePropertyAnnotatorTest.php
M tests/phpunit/includes/ParserDataTest.php
M tests/phpunit/includes/ParserTextProcessorTest.php
M tests/phpunit/includes/hooks/InternalParseBeforeLinksTest.php
M tests/phpunit/includes/hooks/ParserAfterTidyTest.php
M tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
M tests/phpunit/includes/parserhooks/ConceptParserFunctionTest.php
M tests/phpunit/includes/parserhooks/ParserFunctionFactoryTest.php
A tests/phpunit/includes/parserhooks/ParserFunctionIntegrationTest.php
M tests/phpunit/includes/parserhooks/RecurringEventsParserFunctionTest.php
M tests/phpunit/includes/parserhooks/SetParserFunctionTest.php
M tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
M tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
23 files changed, 261 insertions(+), 272 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki 
refs/changes/36/83136/1

diff --git a/SemanticMediaWiki.classes.php b/SemanticMediaWiki.classes.php
index d9ce5df..8c72032 100644
--- a/SemanticMediaWiki.classes.php
+++ b/SemanticMediaWiki.classes.php
@@ -37,7 +37,6 @@
        'SMW\DataValueFactory'      => 'includes/DataValueFactory.php',
 
        'SMWParseData'              => 'includes/SMW_ParseData.php',
-       'SMW\IParserData'           => 'includes/ParserData.php',
        'SMW\ParserData'            => 'includes/ParserData.php',
 
        'SMW\PropertyChangeNotifier'    => 
'includes/PropertyChangeNotifier.php',
diff --git a/includes/ParserData.php b/includes/ParserData.php
index 0cd5755..560d67f 100644
--- a/includes/ParserData.php
+++ b/includes/ParserData.php
@@ -2,161 +2,58 @@
 
 namespace SMW;
 
+use SMWDataValue;
+
 use Title;
-use WikiPage;
 use ParserOutput;
 use MWException;
-use Job;
-
-use SMWStore;
-use SMWDataValue;
-use SMWDIWikiPage;
-use SMWSemanticData;
-use SMWDIProperty;
-use SMWDIBlob;
-use SMWDIBoolean;
-use SMWDITime;
 
 /**
- * Interface handling semantic data storage to a ParserOutput instance
+ * Handling semantic data exchange with a ParserOutput object
  *
  * @since 1.9
  *
  * @file
- * @ingroup SMW
- * @ingroup ParserHooks
  *
  * @author mwjames
+ * @author Markus Krötzsch
  */
-interface IParserData {
-
-       /**
-        * The constructor requires a Title and ParserOutput object
-        */
-
-       /**
-        * Returns Title object
-        *
-        * @since 1.9
-        *
-        * @return Title
-        */
-       public function getTitle();
-
-       /**
-        * Returns ParserOutput object
-        *
-        * @since 1.9
-        *
-        * @return ParserOutput
-        */
-       public function getOutput();
-
-       /**
-        * Update ParserOoutput with processed semantic data
-        *
-        * @since 1.9
-        */
-       public function updateOutput();
-
-       /**
-        * Get semantic data
-        *
-        * @since 1.9
-        *
-        * @return SMWSemanticData
-        */
-       public function getData();
-
-       /**
-        * Clears all data for the given instance
-        *
-        * @since 1.9
-        */
-       public function clearData();
-
-       /**
-        * Updates the store with semantic data fetched from a ParserOutput 
object
-        *
-        * @since 1.9
-        */
-       public function updateStore();
-
-       /**
-        * Returns errors that occurred during processing
-        *
-        * @since 1.9
-        *
-        * @return string
-        */
-       public function getErrors();
-
-}
 
 /**
  * Class that provides access to the semantic data object generated from either
  * the ParserOuput or subject provided (no static binding as in SMWParseData)
  *
  * @ingroup SMW
- * @ingroup ParserHooks
- *
- * @author Markus Krötzsch
- * @author mwjames
  */
-class ParserData extends Observer implements IParserData, DispatchableSubject {
+class ParserData extends Observer implements DispatchableSubject {
 
-       /**
-        * Represents Title object
-        * @var Title
-        */
+       /** @var Title */
        protected $title;
 
-       /**
-        * Represents ParserOutput object
-        * @var ParserOutput
-        */
+       /** @var ParserOutput */
        protected $parserOutput;
 
-       /**
-        * Represents SMWSemanticData object
-        * @var SMWSemanticData
-        */
+       /** @var SemanticData */
        protected $semanticData;
 
-       /**
-        * Represents collected errors
-        * @var array
-        */
+       /** @var array */
        protected $errors = array();
 
-       /**
-        * Represents invoked GLOBALS
-        * @var array
-        */
-       protected $options;
-
-       /**
-        * Represents invoked $smwgEnableUpdateJobs
-        * @var $updateJobs
-        */
+       /** @var $updateJobs */
        protected $updateJobs = true;
 
        /** @var ObservableDispatcher */
        protected $dispatcher;
 
        /**
-        * Constructor
-        *
         * @since 1.9
         *
-        * @param \Title $title
-        * @param \ParserOutput $parserOutput
-        * @param array $options
+        * @param Title $title
+        * @param ParserOutput $parserOutput
         */
-       public function __construct( Title $title, ParserOutput $parserOutput, 
array $options = array() ) {
+       public function __construct( Title $title, ParserOutput $parserOutput ) 
{
                $this->title = $title;
                $this->parserOutput = $parserOutput;
-               $this->options = $options;
                $this->setData();
        }
 
@@ -165,7 +62,7 @@
         *
         * @since 1.9
         *
-        * @return \Title
+        * @return Title
         */
        public function getTitle() {
                return $this->title;
@@ -199,21 +96,21 @@
         *
         * @since 1.9
         *
-        * @return \ParserOutput
+        * @return ParserOutput
         */
        public function getOutput() {
                return $this->parserOutput;
        }
 
        /**
-        * Returns SMWDIWikiPage object
+        * Returns DIWikiPage object
         *
         * @since 1.9
         *
-        * @return \SMWDIWikiPage
+        * @return DIWikiPage
         */
        public function getSubject() {
-               return SMWDIWikiPage::newFromTitle( $this->title );
+               return DIWikiPage::newFromTitle( $this->title );
        }
 
        /**
@@ -254,7 +151,7 @@
         *
         * @since 1.9
         *
-        * @return \SMWSemanticData
+        * @return \SemanticData
         */
        public function getData() {
                return $this->semanticData;
@@ -266,7 +163,7 @@
         * @since 1.9
         */
        public function clearData() {
-               $this->semanticData = new SMWSemanticData( $this->getSubject() 
);
+               $this->semanticData = new SemanticData( $this->getSubject() );
        }
 
        /**
@@ -285,8 +182,8 @@
                }
 
                // Setup data container
-               if ( !( $this->semanticData instanceof SMWSemanticData ) ) {
-                       $this->semanticData = new SMWSemanticData( 
$this->getSubject() );
+               if ( !( $this->semanticData instanceof SemanticData ) ) {
+                       $this->semanticData = new SemanticData( 
$this->getSubject() );
                }
        }
 
@@ -301,7 +198,7 @@
         */
        public function updateOutput(){
 
-               if ( !( $this->semanticData instanceof SMWSemanticData ) ) {
+               if ( !( $this->semanticData instanceof SemanticData ) ) {
                        throw new MWException( 'The semantic data container is 
not available' );
                }
 
diff --git a/includes/ParserTextProcessor.php b/includes/ParserTextProcessor.php
index 1ba0435..e262620 100644
--- a/includes/ParserTextProcessor.php
+++ b/includes/ParserTextProcessor.php
@@ -33,22 +33,13 @@
  */
 class ParserTextProcessor {
 
-       /**
-        * Represents a Settings object
-        * @var Settings
-        */
+       /** @var Settings */
        protected $settings;
 
-       /**
-        * Represents a IParserData object
-        * @var IParserData
-        */
+       /** @var ParserData */
        protected $parserData;
 
-       /**
-        * Represents $smwgNamespacesWithSemanticLinks status
-        * @var boolean
-        */
+       /** @var boolean */
        protected $isEnabled;
 
        /**
@@ -76,10 +67,10 @@
         *
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param Settings $settings
         */
-       public function __construct( IParserData $parserData, Settings 
$settings ) {
+       public function __construct( ParserData $parserData, Settings $settings 
) {
                $this->parserData = $parserData;
                $this->settings = $settings;
        }
diff --git a/includes/parserhooks/AskParserFunction.php 
b/includes/parserhooks/AskParserFunction.php
index 8bbf59e..88c9f9b 100644
--- a/includes/parserhooks/AskParserFunction.php
+++ b/includes/parserhooks/AskParserFunction.php
@@ -27,7 +27,7 @@
  */
 class AskParserFunction {
 
-       /** @var IParserData */
+       /** @var ParserData */
        protected $parserData;
 
        /** @var QueryData */
@@ -46,7 +46,7 @@
         * @param QueryData $queryData
         * @param MessageFormatter $msgFormatter
         */
-       public function __construct( IParserData $parserData, QueryData 
$queryData, MessageFormatter $msgFormatter ) {
+       public function __construct( ParserData $parserData, QueryData 
$queryData, MessageFormatter $msgFormatter ) {
                $this->parserData = $parserData;
                $this->queryData = $queryData;
                $this->msgFormatter = $msgFormatter;
diff --git a/includes/parserhooks/ConceptParserFunction.php 
b/includes/parserhooks/ConceptParserFunction.php
index 4c4487f..6ba9e74 100644
--- a/includes/parserhooks/ConceptParserFunction.php
+++ b/includes/parserhooks/ConceptParserFunction.php
@@ -30,7 +30,7 @@
  */
 class ConceptParserFunction {
 
-       /** @var IParserData */
+       /** @var ParserData */
        protected $parserData;
 
        /** @var MessageFormatter */
@@ -39,10 +39,10 @@
        /**
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param MessageFormatter $msgFormatter
         */
-       public function __construct( IParserData $parserData, MessageFormatter 
$msgFormatter ) {
+       public function __construct( ParserData $parserData, MessageFormatter 
$msgFormatter ) {
                $this->parserData = $parserData;
                $this->msgFormatter = $msgFormatter;
        }
diff --git a/includes/parserhooks/RecurringEventsParserFunction.php 
b/includes/parserhooks/RecurringEventsParserFunction.php
index deb51ee..345d93e 100644
--- a/includes/parserhooks/RecurringEventsParserFunction.php
+++ b/includes/parserhooks/RecurringEventsParserFunction.php
@@ -33,13 +33,13 @@
        /**
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param Subobject $subobject
         * @param MessageFormatter $msgFormatter
         * @param Settings $settings
         */
        public function __construct(
-               IParserData $parserData,
+               ParserData $parserData,
                Subobject $subobject,
                MessageFormatter $msgFormatter,
                Settings $settings
diff --git a/includes/parserhooks/SetParserFunction.php 
b/includes/parserhooks/SetParserFunction.php
index 8971d9e..117fa24 100644
--- a/includes/parserhooks/SetParserFunction.php
+++ b/includes/parserhooks/SetParserFunction.php
@@ -27,7 +27,7 @@
  */
 class SetParserFunction {
 
-       /** @var IParserDate */
+       /** @var ParserDate */
        protected $parserData;
 
        /** @var MessageFormatter */
@@ -36,10 +36,10 @@
        /**
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param MessageFormatter $msgFormatter
         */
-       public function __construct( IParserData $parserData, MessageFormatter 
$msgFormatter ) {
+       public function __construct( ParserData $parserData, MessageFormatter 
$msgFormatter ) {
                $this->parserData = $parserData;
                $this->msgFormatter = $msgFormatter;
        }
diff --git a/includes/parserhooks/ShowParserFunction.php 
b/includes/parserhooks/ShowParserFunction.php
index f99c71c..9b8999d 100644
--- a/includes/parserhooks/ShowParserFunction.php
+++ b/includes/parserhooks/ShowParserFunction.php
@@ -24,7 +24,7 @@
  */
 class ShowParserFunction {
 
-       /** @var IParserData */
+       /** @var ParserData */
        protected $parserData;
 
        /** @var QueryData */
@@ -36,11 +36,11 @@
        /**
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param QueryData $queryData
         * @param MessageFormatter $messageList
         */
-       public function __construct( IParserData $parserData, QueryData 
$queryData, MessageFormatter $msgFormatter ) {
+       public function __construct( ParserData $parserData, QueryData 
$queryData, MessageFormatter $msgFormatter ) {
                $this->parserData = $parserData;
                $this->queryData = $queryData;
                $this->msgFormatter = $msgFormatter;
diff --git a/includes/parserhooks/SubobjectParserFunction.php 
b/includes/parserhooks/SubobjectParserFunction.php
index 5ebb74d..231f9fc 100644
--- a/includes/parserhooks/SubobjectParserFunction.php
+++ b/includes/parserhooks/SubobjectParserFunction.php
@@ -24,7 +24,7 @@
  */
 class SubobjectParserFunction {
 
-       /** @var IParserData */
+       /** @var ParserData */
        protected $parserData;
 
        /** @var Subobject */
@@ -39,11 +39,11 @@
        /**
         * @since 1.9
         *
-        * @param IParserData $parserData
+        * @param ParserData $parserData
         * @param Subobject $subobject
         * @param MessageFormatter $msgFormatter
         */
-       public function __construct( IParserData $parserData, Subobject 
$subobject, MessageFormatter $msgFormatter ) {
+       public function __construct( ParserData $parserData, Subobject 
$subobject, MessageFormatter $msgFormatter ) {
                $this->parserData = $parserData;
                $this->subobject = $subobject;
                $this->msgFormatter = $msgFormatter;
diff --git a/tests/phpunit/ParserTestCase.php b/tests/phpunit/ParserTestCase.php
index e192959..cf24800 100644
--- a/tests/phpunit/ParserTestCase.php
+++ b/tests/phpunit/ParserTestCase.php
@@ -93,12 +93,11 @@
         *
         * @param Title $title
         * @param ParserOutput $parserOutput
-        * @param array $settings
         *
         * @return ParserData
         */
-       protected function getParserData( Title $title, ParserOutput 
$parserOutput, array $settings = array() ) {
-               return new ParserData( $title, $parserOutput, $settings );
+       protected function newParserData( Title $title, ParserOutput 
$parserOutput ) {
+               return new ParserData( $title, $parserOutput );
        }
 
        /**
@@ -112,7 +111,7 @@
         */
        protected function getParserTextProcessor( Title $title, ParserOutput 
$parserOutput, Settings $settings ) {
                return new ParserTextProcessor(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        $settings
                );
        }
diff --git a/tests/phpunit/includes/BasePropertyAnnotatorTest.php 
b/tests/phpunit/includes/BasePropertyAnnotatorTest.php
index 0ecc1b0..a2ccfff 100644
--- a/tests/phpunit/includes/BasePropertyAnnotatorTest.php
+++ b/tests/phpunit/includes/BasePropertyAnnotatorTest.php
@@ -153,7 +153,7 @@
                // Test "real" observer integration
                $title        = $subject->getTitle();
                $parserOutput = $this->newParserOutput();
-               $parserData   = $this->getParserData( $title, $parserOutput );
+               $parserData   = $this->newParserData( $title, $parserOutput );
 
                // Create instance and attach mock Observer
                $instance = $this->newInstance( $parserData->getData(), 
$setup['settings'] );
@@ -161,7 +161,7 @@
                $instance->addCategories( $setup['categories'] );
 
                // Re-read data from the $parserOutput object
-               $newParserData = $this->getParserData( $title, $parserOutput );
+               $newParserData = $this->newParserData( $title, $parserOutput );
 
                $this->assertSemanticData(
                        $newParserData->getData(),
diff --git a/tests/phpunit/includes/ParserDataTest.php 
b/tests/phpunit/includes/ParserDataTest.php
index f4ffd80..91b958a 100644
--- a/tests/phpunit/includes/ParserDataTest.php
+++ b/tests/phpunit/includes/ParserDataTest.php
@@ -49,12 +49,17 @@
         *
         * @return ParserData
         */
-       private function newInstance( Title $title, ParserOutput $parserOutput, 
array $settings = array() ) {
-               return new ParserData(
-                       $title,
-                       $parserOutput,
-                       $settings
-               );
+       private function newInstance( Title $title = null, ParserOutput 
$parserOutput = null ) {
+
+               if ( $title === null ) {
+                       $title = $this->newTitle();
+               }
+
+               if ( $parserOutput === null ) {
+                       $parserOutput = $this->newParserOutput();
+               }
+
+               return new ParserData( $title, $parserOutput );
        }
 
        /**
@@ -63,11 +68,7 @@
         * @since 1.9
         */
        public function testConstructor() {
-               $instance = $this->newInstance(
-                       $this->newTitle(),
-                       $this->newParserOutput()
-               );
-               $this->assertInstanceOf( $this->getClass(), $instance );
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
        }
 
        /**
@@ -96,10 +97,7 @@
         */
        public function testAddDataValue( $propertyName, $value, $errorCount, 
$propertyCount ) {
 
-               $instance = $this->newInstance(
-                       $this->getTitle(),
-                       $this->getParserOutput()
-               );
+               $instance = $this->newInstance();
 
                $instance->addDataValue(
                        DataValueFactory::newPropertyValue(
diff --git a/tests/phpunit/includes/ParserTextProcessorTest.php 
b/tests/phpunit/includes/ParserTextProcessorTest.php
index ef80bb1..0575cf2 100644
--- a/tests/phpunit/includes/ParserTextProcessorTest.php
+++ b/tests/phpunit/includes/ParserTextProcessorTest.php
@@ -226,7 +226,7 @@
         */
        private function getInstance( Title $title, ParserOutput $parserOutput, 
array $settings = array() ) {
                return new ParserTextProcessor(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        $this->newSettings( $settings )
                );
        }
@@ -272,7 +272,7 @@
                $this->assertEquals( $expected, $result );
 
                // Check values against ParserData/ParserOutput object
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                if ( method_exists( $parserOutput, 'getExtensionData' ) ) {
                        $this->assertEquals( $expected, 
$parserData->getOutput()->getExtensionData( 'smwmagicwords' ) );
@@ -305,7 +305,7 @@
                $this->assertContains( $expected['resultText'], $text );
 
                // Re-read data from stored parserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf( '\SMW\SemanticData', 
$parserData->getData() );
@@ -332,7 +332,7 @@
                        'smwgInlineErrors'  => true,
                ) );
 
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                $instance = new ParserTextProcessor( $parserData, $settings );
                $instance->parse( $text );
diff --git a/tests/phpunit/includes/hooks/InternalParseBeforeLinksTest.php 
b/tests/phpunit/includes/hooks/InternalParseBeforeLinksTest.php
index 2aa564a..9c4d868 100644
--- a/tests/phpunit/includes/hooks/InternalParseBeforeLinksTest.php
+++ b/tests/phpunit/includes/hooks/InternalParseBeforeLinksTest.php
@@ -118,7 +118,7 @@
                );
 
                // Re-read data from the Parser
-               $parserData = $this->getParserData( $parser->getTitle(), 
$parser->getOutput() );
+               $parserData = $this->newParserData( $parser->getTitle(), 
$parser->getOutput() );
                $this->assertSemanticData(
                        $parserData->getData(),
                        $expected,
diff --git a/tests/phpunit/includes/hooks/ParserAfterTidyTest.php 
b/tests/phpunit/includes/hooks/ParserAfterTidyTest.php
index 29aba20..329c938 100644
--- a/tests/phpunit/includes/hooks/ParserAfterTidyTest.php
+++ b/tests/phpunit/includes/hooks/ParserAfterTidyTest.php
@@ -171,7 +171,7 @@
                );
 
                // Re-read data from the Parser
-               $parserData = $this->getParserData( $title, 
$parser->getOutput() );
+               $parserData = $this->newParserData( $title, 
$parser->getOutput() );
                $this->assertSemanticData(
                        $parserData->getData(),
                        $expected,
diff --git a/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
index d52c2c4..b24e900 100644
--- a/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/AskParserFunctionTest.php
@@ -67,7 +67,7 @@
                }
 
                return new AskParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new QueryData( $title ),
                        new MessageFormatter( $title->getPageLanguage() ),
                        $settings
@@ -172,7 +172,7 @@
                $instance->parse( $params );
 
                // Get semantic data from the ParserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf( 'SMWSemanticData', 
$parserData->getData() );
diff --git a/tests/phpunit/includes/parserhooks/ConceptParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/ConceptParserFunctionTest.php
index 31f991e..afe8f93 100644
--- a/tests/phpunit/includes/parserhooks/ConceptParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/ConceptParserFunctionTest.php
@@ -55,7 +55,7 @@
                }
 
                return new ConceptParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new MessageFormatter( $title->getPageLanguage() )
                );
        }
@@ -144,7 +144,7 @@
                $instance->parse( $params );
 
                // Re-read data from stored parserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf(
diff --git a/tests/phpunit/includes/parserhooks/ParserFunctionFactoryTest.php 
b/tests/phpunit/includes/parserhooks/ParserFunctionFactoryTest.php
index 1e30f8b..0e7bcaf 100644
--- a/tests/phpunit/includes/parserhooks/ParserFunctionFactoryTest.php
+++ b/tests/phpunit/includes/parserhooks/ParserFunctionFactoryTest.php
@@ -4,9 +4,6 @@
 
 use SMW\ParserFunctionFactory;
 
-use WikiPage;
-use Parser;
-
 /**
  * Tests for the ParserFunctionFactory class
  *
@@ -47,8 +44,8 @@
         *
         * @return ParserFunctionFactory
         */
-       private function getInstance() {
-               return ParserFunctionFactory::newFromParser( $this->getParser( 
$this->newTitle(), $this->getUser() ) );
+       private function newInstance() {
+               return ParserFunctionFactory::newFromParser( $this->newParser( 
$this->newTitle(), $this->getUser() ) );
        }
 
        /**
@@ -57,24 +54,30 @@
         * @since 1.9
         */
        public function testConstructor() {
-               $this->assertInstanceOf( $this->getClass(), 
$this->getInstance() );
-       }
-
-       /**
-        * @test ParserFunctionFactory::getSubobjectParser
-        *
-        * @since 1.9
-        */
-       public function testGetSubobjectParser() {
-               $this->assertInstanceOf( '\SMW\SubobjectParserFunction', 
$this->getInstance()->getSubobjectParser() );
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
        }
 
        /**
         * @test ParserFunctionFactory::getRecurringEventsParser
+        * @dataProvider parserFunctionDataProvider
         *
         * @since 1.9
         */
-       public function testGetRecurringEventsParser() {
-               $this->assertInstanceOf( '\SMW\RecurringEventsParserFunction', 
$this->getInstance()->getRecurringEventsParser() );
+       public function testParserFunction( $instance, $method ) {
+               $this->assertInstanceOf( $instance, call_user_func_array( 
array( $this->newInstance(), $method ), array() ) );
        }
+
+       /**
+        * @return array
+        */
+       public function parserFunctionDataProvider() {
+
+               $provider = array();
+
+               $provider[] = array( '\SMW\RecurringEventsParserFunction', 
'getRecurringEventsParser' );
+               $provider[] = array( '\SMW\SubobjectParserFunction',       
'getSubobjectParser' );
+
+               return $provider;
+       }
+
 }
diff --git 
a/tests/phpunit/includes/parserhooks/ParserFunctionIntegrationTest.php 
b/tests/phpunit/includes/parserhooks/ParserFunctionIntegrationTest.php
new file mode 100644
index 0000000..189aa49
--- /dev/null
+++ b/tests/phpunit/includes/parserhooks/ParserFunctionIntegrationTest.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\ContentParser;
+
+use Title;
+
+/**
+ * Integration tests for registered ParserFunction
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @since   1.9
+ *
+ * @author mwjames
+ */
+
+/**
+ * @covers \SMW\ContentParser
+ * @covers \SMW\AskParserFunction
+ * @covers \SMW\ShowParserFunction
+ *
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+class ParserFunctionIntegrationTest extends SemanticMediaWikiTestCase {
+
+       /**
+        * Returns the name of the class to be tested
+        *
+        * @return string|false
+        */
+       public function getClass() {
+               return false;
+       }
+
+       /**
+        * Helper method that returns a ContentParser object
+        *
+        * @since 1.9
+        *
+        * @return ContentParser
+        */
+       private function newInstance( Title $title = null ) {
+
+               if( $title === null ) {
+                       $title = $this->newTitle();
+               }
+
+               return new ContentParser( $title );
+       }
+
+       /**
+        * Check that registered parser functions (especially those as 
closures) are
+        * generally executable during parsing of a standard text
+        *
+        * @test ContentParser::parse
+        * @dataProvider textDataProvider
+        *
+        * @since 1.9
+        */
+       public function testParseFromText( $text ) {
+
+               $instance = $this->newInstance();
+               $instance->setText( $text )->parse();
+
+               $this->assertInstanceOf(
+                       'ParserOutput', $instance->getOutput(),
+                       'asstert that a ParserOutput object is available'
+                       );
+
+               $this->assertInternalType(
+                       'string',
+                       $instance->getOutput()->getText(),
+                       'asserts that getText() is returning a string'
+               );
+
+       }
+
+       /**
+        * @return array
+        */
+       public function textDataProvider() {
+
+               $provider = array();
+
+               // #0 AskParserFunction
+               $provider[] = array( $this->newRandomString() . '{{#ask: 
[[Modification date::+]]|limit=1}}' );
+
+               // #1 ShowParserFunction
+               $provider[] = array( $this->newRandomString() . '{{#show: 
[[Foo]]|limit=1}}' );
+
+               // #2 SubobjectParserFunction
+               $provider[] = array( $this->newRandomString() . 
'{{#subobject:|foo=bar|lila=lula,linda,luna|+sep=,}}' );
+
+               // #3 RecurringEventsParserFunction
+               // Test against 'Exception' with message 'Serialization of 
'Closure' and Parser->braceSubstitution
+               $provider[] = array( $this->newRandomString() . 
'{{#set_recurring_event:some more tests|property=has date|' .
+                       'has title=Some recurring title|title2|has 
group=Events123|Events456|start=June 8, 2010|end=June 8, 2011|' .
+                       
'unit=week|period=1|limit=10|duration=7200|include=March 16, 2010;March 23, 
2010|+sep=;|' .
+                       'exclude=March 15, 2010;March 22, 2010|+sep=;}}' );
+
+               return $provider;
+       }
+
+}
diff --git 
a/tests/phpunit/includes/parserhooks/RecurringEventsParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/RecurringEventsParserFunctionTest.php
index 4ff136b..efa84a5 100644
--- a/tests/phpunit/includes/parserhooks/RecurringEventsParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/RecurringEventsParserFunctionTest.php
@@ -9,7 +9,6 @@
 
 use Title;
 use ParserOutput;
-use ReflectionClass;
 
 /**
  * Tests for the RecurringEventsParserFunction class.
@@ -51,12 +50,21 @@
         *
         * @return RecurringEventsParserFunction
         */
-       private function getInstance( Title $title, ParserOutput $parserOutput 
= null ) {
+       private function newInstance( Title $title = null, ParserOutput 
$parserOutput = null ) {
+
+               if ( $title === null ) {
+                       $title = $this->newTitle();
+               }
+
+               if ( $parserOutput === null ) {
+                       $parserOutput = $this->newParserOutput();
+               }
+
                return new RecurringEventsParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new Subobject( $title ),
                        new MessageFormatter( $title->getPageLanguage() ),
-                       $this->getSettings( array(
+                       $this->newSettings( array(
                                'smwgDefaultNumRecurringEvents' => 100,
                                'smwgMaxNumRecurringEvents' => 100
                        ) )
@@ -69,23 +77,12 @@
         * @since 1.9
         */
        public function testConstructor() {
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
-               $this->assertInstanceOf( $this->getClass(), $instance );
-       }
-
-       /**
-        * @test RecurringEventsParserFunction::__construct (Test exception)
-        *
-        * @since 1.9
-        */
-       public function testConstructorException() {
-               $this->setExpectedException( 'PHPUnit_Framework_Error' );
-               $instance = new $this->getInstance( $this->newTitle() );
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
        }
 
        /**
         * @test RecurringEventsParserFunction::parse
-        * @dataProvider getRecurringEventsDataProvider
+        * @dataProvider recurringEventsDataProvider
         *
         * @since 1.9
         *
@@ -94,14 +91,14 @@
         */
        public function testParse( array $params, array $expected ) {
 
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
+               $instance = $this->newInstance( $this->newTitle(), 
$this->newParserOutput() );
                $result = $instance->parse( $this->getParserParameterFormatter( 
$params ) );
 
                $this->assertTrue( $result !== '' ? $expected['errors'] : 
!$expected['errors'] );
 
                // Access protected property
-               $reflection = new ReflectionClass( $this->getClass() );
-               $events = $reflection->getProperty( 'events' );
+               $reflector = $this->newReflector();
+               $events = $reflector->getProperty( 'events' );
                $events->setAccessible( true );
 
                $this->assertEquals( $expected['parameters'], 
$events->getValue( $instance )->getParameters() );
@@ -114,7 +111,7 @@
         * @since 1.9
         */
        public function testStaticRender() {
-               $parser = $this->getParser( $this->newTitle(), $this->getUser() 
);
+               $parser = $this->newParser( $this->newTitle(), $this->getUser() 
);
                $result = RecurringEventsParserFunction::render( $parser );
                $this->assertInternalType( 'string', $result );
        }
@@ -127,7 +124,7 @@
         *
         * @return array
         */
-       public function getRecurringEventsDataProvider() {
+       public function recurringEventsDataProvider() {
                return array(
                        // #0
                        // {{#set_recurring_event:property=Has birthday
diff --git a/tests/phpunit/includes/parserhooks/SetParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/SetParserFunctionTest.php
index 5af9f28..aa6dc65 100644
--- a/tests/phpunit/includes/parserhooks/SetParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/SetParserFunctionTest.php
@@ -119,9 +119,18 @@
         *
         * @return  SetParserFunction
         */
-       private function getInstance( Title $title, ParserOutput $parserOutput 
= null ) {
+       private function newInstance( Title $title = null, ParserOutput 
$parserOutput = null ) {
+
+               if ( $title === null ) {
+                       $title = $this->newTitle();
+               }
+
+               if ( $parserOutput === null ) {
+                       $parserOutput = $this->newParserOutput();
+               }
+
                return new SetParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new MessageFormatter( $title->getPageLanguage() )
                );
        }
@@ -132,18 +141,7 @@
         * @since 1.9
         */
        public function testConstructor() {
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
-               $this->assertInstanceOf( $this->getClass(), $instance );
-       }
-
-       /**
-        * @test SetParserFunction::__construct (Test instance exception)
-        *
-        * @since 1.9
-        */
-       public function testConstructorException() {
-               $this->setExpectedException( 'PHPUnit_Framework_Error' );
-               $instance =  $this->getInstance( $this->getTitle() );
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
        }
 
        /**
@@ -156,7 +154,7 @@
         * @param array $expected
         */
        public function testParse( array $params, array $expected ) {
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
+               $instance = $this->newInstance( $this->newTitle(), 
$this->newParserOutput() );
                $result = $instance->parse( $this->getParserParameterFormatter( 
$params ) );
 
                $this->assertInternalType( 'string', $result );
@@ -177,11 +175,11 @@
                $title        = $this->newTitle();
 
                // Initialize and parse
-               $instance = $this->getInstance( $title, $parserOutput );
+               $instance = $this->newInstance( $title, $parserOutput );
                $instance->parse( $this->getParserParameterFormatter( $params ) 
);
 
                // Re-read data from stored parserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf( '\SMW\SemanticData', 
$parserData->getData() );
@@ -194,7 +192,7 @@
         * @since 1.9
         */
        public function testStaticRender() {
-               $parser = $this->getParser( $this->newTitle(), $this->getUser() 
);
+               $parser = $this->newParser( $this->newTitle(), $this->getUser() 
);
                $result = SetParserFunction::render( $parser );
                $this->assertInternalType( 'string', $result );
        }
diff --git a/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
index 0f4e29c..b9ceb72 100644
--- a/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
@@ -8,7 +8,6 @@
 
 use Title;
 use ParserOutput;
-use ReflectionClass;
 
 /**
  * Tests for the ShowParserFunction class
@@ -63,7 +62,7 @@
                $settings = $this->newSettings();
 
                return new ShowParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new QueryData( $title ),
                        new MessageFormatter( $title->getPageLanguage() ),
                        $settings
@@ -116,8 +115,8 @@
                $instance = $this->newInstance( $title, 
$this->getParserOutput() );
 
                // Make protected method accessible
-               $reflection = new ReflectionClass( $this->getClass() );
-               $method = $reflection->getMethod( 'disabled' );
+               $reflector = $this->newReflector();
+               $method = $reflector->getMethod( 'disabled' );
                $method->setAccessible( true );
 
                $result = $method->invoke( $instance );
@@ -143,7 +142,7 @@
                $instance->parse( $params );
 
                // Get semantic data from the ParserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf( '\SMW\SemanticData', 
$parserData->getData() );
@@ -162,7 +161,7 @@
         * @since 1.9
         */
        public function testStaticRender() {
-               $parser = $this->getParser( $this->newTitle(), $this->getUser() 
);
+               $parser = $this->newParser( $this->newTitle(), $this->getUser() 
);
                $result = ShowParserFunction::render( $parser );
                $this->assertInternalType( 'string', $result );
        }
diff --git a/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php 
b/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
index 3f3c993..e7825da 100644
--- a/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
@@ -52,9 +52,18 @@
         *
         * @return SubobjectParserFunction
         */
-       private function getInstance( Title $title, ParserOutput $parserOutput 
= null ) {
+       private function newInstance( Title $title= null, ParserOutput 
$parserOutput = null ) {
+
+               if ( $title === null ) {
+                       $title = $this->newTitle();
+               }
+
+               if ( $parserOutput === null ) {
+                       $parserOutput = $this->newParserOutput();
+               }
+
                return new SubobjectParserFunction(
-                       $this->getParserData( $title, $parserOutput ),
+                       $this->newParserData( $title, $parserOutput ),
                        new Subobject( $title ),
                        new MessageFormatter( $title->getPageLanguage() )
                );
@@ -66,18 +75,7 @@
         * @since 1.9
         */
        public function testConstructor() {
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
-               $this->assertInstanceOf( $this->getClass(), $instance );
-       }
-
-       /**
-        * @test SubobjectParserFunction::__construct
-        *
-        * @since 1.9
-        */
-       public function testConstructorException() {
-               $this->setExpectedException( 'PHPUnit_Framework_Error' );
-               $instance = new $this->getInstance( $this->newTitle() );
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
        }
 
        /**
@@ -91,7 +89,7 @@
         */
        public function testParse( array $params, array $expected ) {
 
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
+               $instance = $this->newInstance( $this->newTitle(), 
$this->newParserOutput() );
                $result   = $instance->parse( 
$this->getParserParameterFormatter( $params ) );
 
                $this->assertEquals( $result !== '' , $expected['errors'] );
@@ -109,7 +107,7 @@
         */
        public function testInstantiatedSubobject( array $params, array 
$expected ) {
 
-               $instance = $this->getInstance( $this->newTitle(), 
$this->newParserOutput() );
+               $instance = $this->newInstance( $this->newTitle(), 
$this->newParserOutput() );
                $instance->parse( $this->getParserParameterFormatter( $params ) 
);
 
                $this->assertContains( $expected['identifier'], 
$instance->getSubobject()->getId() );
@@ -132,7 +130,7 @@
                $title        = $this->newTitle();
 
                // Initialize and parse
-               $instance = $this->getInstance( $title, $parserOutput );
+               $instance = $this->newInstance( $title, $parserOutput );
                $instance->setObjectReference( $isEnabled );
                $instance->parse( $this->getParserParameterFormatter( $params ) 
);
 
@@ -142,7 +140,7 @@
                $this->assertEquals( $expected['identifier'], $isEnabled ? 
$id{0} : $id, $info['msg'] );
 
                // Get data instance
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Add generated title text as property value due to the auto 
reference
                // setting
@@ -171,11 +169,11 @@
                $title        = $this->newTitle();
 
                // Initialize and parse
-               $instance = $this->getInstance( $title, $parserOutput );
+               $instance = $this->newInstance( $title, $parserOutput );
                $instance->parse( $this->getParserParameterFormatter( $params ) 
);
 
                // Get semantic data from the ParserOutput
-               $parserData = $this->getParserData( $title, $parserOutput );
+               $parserData = $this->newParserData( $title, $parserOutput );
 
                // Check the returned instance
                $this->assertInstanceOf( '\SMW\SemanticData', 
$parserData->getData() );
@@ -194,7 +192,7 @@
         */
        public function testStaticRender() {
 
-               $parser = $this->getParser( $this->newTitle(), $this->getUser() 
);
+               $parser = $this->newParser( $this->newTitle(), $this->getUser() 
);
                $result = SubobjectParserFunction::render( $parser );
 
                $this->assertInternalType( 'string', $result );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb3245485a188e37463552522f3b6d58449ecfca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>

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

Reply via email to