Mwjames has uploaded a new change for review.

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


Change subject: Some \SMW\ namespace clean-up
......................................................................

Some \SMW\ namespace clean-up

Change-Id: I298f6b097769d62d34ac0633b6e04c3ed3c2d1d6
---
M includes/Highlighter.php
M includes/SMW_SemanticData.php
M includes/Subobject.php
M includes/utilities/ArrayAccessor.php
M includes/utilities/NamespaceExaminer.php
M includes/utilities/Profiler.php
M tests/phpunit/MockObjectBuilder.php
M tests/phpunit/SemanticMediaWikiTestCase.php
M tests/phpunit/includes/HighlighterTest.php
M tests/phpunit/includes/NamespaceExaminerTest.php
M tests/phpunit/includes/SubobjectTest.php
M tests/phpunit/includes/utilities/ArrayAccessorTest.php
M tests/phpunit/includes/utilities/ProfilerTest.php
13 files changed, 125 insertions(+), 115 deletions(-)


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

diff --git a/includes/Highlighter.php b/includes/Highlighter.php
index b887886..c98e789 100644
--- a/includes/Highlighter.php
+++ b/includes/Highlighter.php
@@ -1,7 +1,14 @@
 <?php
 
 namespace SMW;
-use MWException, IContextSource, Html, SMWOutputs;
+
+use SMWOutputs;
+
+use IContextSource;
+use ContextSource;
+use Html;
+
+use MWException;
 
 /**
  * Highlighter utility function for Semantic MediaWiki
@@ -20,14 +27,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
  *
- * @since 1.9
- *
  * @file
- * @ingroup SMW
+ *
+ * @license GNU GPL v2+
+ * @since   1.9
  *
  * @author mwjames
  */
-class Highlighter extends \ContextSource {
+
+/**
+ * Highlighter utility function for Semantic MediaWiki
+ *
+ * @ingroup SMW
+ */
+class Highlighter extends ContextSource {
 
        // Highlighter ID for no types
        const TYPE_NOTYPE    = 0;
diff --git a/includes/SMW_SemanticData.php b/includes/SMW_SemanticData.php
index 4d1706a..f4f9e08 100644
--- a/includes/SMW_SemanticData.php
+++ b/includes/SMW_SemanticData.php
@@ -531,7 +531,7 @@
 }
 
 /**
- * SMWSemanticData class alias
+ * SMW\SemanticData class alias
  *
  * @since 1.9
  */
diff --git a/includes/Subobject.php b/includes/Subobject.php
index ea3e332..e591462 100644
--- a/includes/Subobject.php
+++ b/includes/Subobject.php
@@ -4,9 +4,7 @@
 
 use SMWContainerSemanticData;
 use SMWDIContainer;
-use SMWDIWikiPage;
 use SMWDataValue;
-use SMWDIProperty;
 
 use Title;
 
@@ -28,10 +26,10 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
- * @ingroup SMW
+ *
+ * @license GNU GPL v2+
+ * @since   1.9
  *
  * @author mwjames
  */
@@ -148,7 +146,7 @@
                if ( $identifier != '' ) {
                        $this->identifier = $identifier;
 
-                       $diSubWikiPage = new SMWDIWikiPage(
+                       $diSubWikiPage = new DIWikiPage(
                                $this->title->getDBkey(),
                                $this->title->getNamespace(),
                                $this->title->getInterwiki(),
@@ -176,10 +174,10 @@
         *
         * @since 1.9
         *
-        * @return SMWDIProperty
+        * @return DIProperty
         */
        public function getProperty() {
-               return new SMWDIProperty( SMWDIProperty::TYPE_SUBOBJECT );
+               return new DIProperty( DIProperty::TYPE_SUBOBJECT );
        }
 
        /**
@@ -217,7 +215,7 @@
 
                wfProfileIn( __METHOD__ );
 
-               if ( $dataValue->getProperty() instanceof SMWDIProperty ) {
+               if ( $dataValue->getProperty() instanceof DIProperty ) {
                        if ( $dataValue->isValid() ) {
                                $this->semanticData->addPropertyObjectValue(
                                        $dataValue->getProperty(),
@@ -225,7 +223,7 @@
                                );
                        } else {
                                $this->semanticData->addPropertyObjectValue(
-                                       new SMWDIProperty( 
SMWDIProperty::TYPE_ERROR ),
+                                       new DIProperty( DIProperty::TYPE_ERROR 
),
                                        
$dataValue->getProperty()->getDiWikiPage()
                                );
                                $this->addError( $dataValue->getErrors() );
diff --git a/includes/utilities/ArrayAccessor.php 
b/includes/utilities/ArrayAccessor.php
index a354d62..313aabd 100644
--- a/includes/utilities/ArrayAccessor.php
+++ b/includes/utilities/ArrayAccessor.php
@@ -23,11 +23,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
  * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 interface Accessor {
diff --git a/includes/utilities/NamespaceExaminer.php 
b/includes/utilities/NamespaceExaminer.php
index 0a4c044..6f160e9 100644
--- a/includes/utilities/NamespaceExaminer.php
+++ b/includes/utilities/NamespaceExaminer.php
@@ -23,11 +23,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
diff --git a/includes/utilities/Profiler.php b/includes/utilities/Profiler.php
index 4cd0e13..6ce5b98 100644
--- a/includes/utilities/Profiler.php
+++ b/includes/utilities/Profiler.php
@@ -20,11 +20,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
  * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
diff --git a/tests/phpunit/MockObjectBuilder.php 
b/tests/phpunit/MockObjectBuilder.php
index 67d4e9d..f0a28cb 100644
--- a/tests/phpunit/MockObjectBuilder.php
+++ b/tests/phpunit/MockObjectBuilder.php
@@ -213,6 +213,35 @@
 
                return $revision;
        }
+
+       /**
+        * Returns a DataValue object
+        *
+        * @since 1.9
+        *
+        * @return DataValue
+        */
+       public function getMockDataValue() {
+
+               $dataValue = $this->getMockBuilder( $this->set( 'DataValueType' 
) )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $dataValue->expects( $this->any() )
+                       ->method( 'getProperty' )
+                       ->will( $this->returnValue( $this->set( 'getProperty' ) 
) );
+
+               $dataValue->expects( $this->any() )
+                       ->method( 'isValid' )
+                       ->will( $this->returnValue( $this->set( 'isValid' ) ) );
+
+               $dataValue->expects( $this->any() )
+                       ->method( 'getDataItem' )
+                       ->will( $this->returnValue( $this->set( 'getDataItem' ) 
) );
+
+               return $dataValue;
+       }
+
        /**
         * Returns a SMWQueryResult object
         *
diff --git a/tests/phpunit/SemanticMediaWikiTestCase.php 
b/tests/phpunit/SemanticMediaWikiTestCase.php
index 2cd8743..792bad4 100644
--- a/tests/phpunit/SemanticMediaWikiTestCase.php
+++ b/tests/phpunit/SemanticMediaWikiTestCase.php
@@ -4,6 +4,7 @@
 
 use SMW\DataValueFactory;
 use SMW\ArrayAccessor;
+use SMW\SemanticData;
 use SMW\DIWikiPage;
 use SMW\Settings;
 
@@ -15,7 +16,6 @@
 
 use ReflectionClass;
 
-use SMWSemanticData;
 use SMWDataItem;
 
 /**
@@ -245,15 +245,15 @@
         * 'propertyLabel' => array() or 'propertyKey' => array()
         * 'propertyValue' => array()
         *
-        * @param SMWSemanticData $semanticData
+        * @param SemanticData $semanticData
         * @param array $expected
         */
-       protected function assertSemanticData( SMWSemanticData $semanticData, 
array $expected ) {
+       protected function assertSemanticData( SemanticData $semanticData, 
array $expected ) {
                $this->assertCount( $expected['propertyCount'], 
$semanticData->getProperties() );
 
                // Assert expected properties
                foreach ( $semanticData->getProperties() as $key => $diproperty 
) {
-                       $this->assertInstanceOf( 'SMWDIProperty', $diproperty );
+                       $this->assertInstanceOf( '\SMW\DIProperty', $diproperty 
);
 
                        if ( isset( $expected['propertyKey']) ){
                                $this->assertContains( $diproperty->getKey(), 
$expected['propertyKey'] );
diff --git a/tests/phpunit/includes/HighlighterTest.php 
b/tests/phpunit/includes/HighlighterTest.php
index c4ead66..c40c250 100644
--- a/tests/phpunit/includes/HighlighterTest.php
+++ b/tests/phpunit/includes/HighlighterTest.php
@@ -22,17 +22,15 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
- * @ingroup Test
  *
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
 /**
- * Tests for the Highlighter class
  * @covers \SMW\Highlighter
  *
  * @ingroup Test
@@ -49,29 +47,6 @@
         */
        public function getClass() {
                return '\SMW\Highlighter';
-       }
-
-       /**
-        * Provides test sample
-        *
-        * @return array
-        */
-       public function getTypeDataProvider() {
-               return array(
-                       array( '' , Highlighter::TYPE_NOTYPE ),
-                       array( 'property', Highlighter::TYPE_PROPERTY ),
-                       array( 'text', Highlighter::TYPE_TEXT ),
-                       array( 'info', Highlighter::TYPE_INFO ),
-                       array( 'help', Highlighter::TYPE_HELP ),
-                       array( 'service', Highlighter::TYPE_SERVICE ),
-                       array( 'quantity', Highlighter::TYPE_QUANTITY ),
-                       array( 'note', Highlighter::TYPE_NOTE ),
-                       array( 'warning', Highlighter::TYPE_WARNING ),
-                       array( 'PrOpErTy', Highlighter::TYPE_PROPERTY ),
-                       array( 'バカなテスト', Highlighter::TYPE_NOTYPE ),
-                       array( '<span>Something that should not work</span>', 
Highlighter::TYPE_NOTYPE ),
-                       array( Highlighter::TYPE_PROPERTY, 
Highlighter::TYPE_NOTYPE )
-               );
        }
 
        /**
@@ -130,4 +105,28 @@
                // Check with caption/content set
                $this->assertInternalType( 'string', $instance->getHtml() );
        }
+
+       /**
+        * Provides test sample
+        *
+        * @return array
+        */
+       public function getTypeDataProvider() {
+               return array(
+                       array( '' , Highlighter::TYPE_NOTYPE ),
+                       array( 'property', Highlighter::TYPE_PROPERTY ),
+                       array( 'text', Highlighter::TYPE_TEXT ),
+                       array( 'info', Highlighter::TYPE_INFO ),
+                       array( 'help', Highlighter::TYPE_HELP ),
+                       array( 'service', Highlighter::TYPE_SERVICE ),
+                       array( 'quantity', Highlighter::TYPE_QUANTITY ),
+                       array( 'note', Highlighter::TYPE_NOTE ),
+                       array( 'warning', Highlighter::TYPE_WARNING ),
+                       array( 'PrOpErTy', Highlighter::TYPE_PROPERTY ),
+                       array( 'バカなテスト', Highlighter::TYPE_NOTYPE ),
+                       array( '<span>Something that should not work</span>', 
Highlighter::TYPE_NOTYPE ),
+                       array( Highlighter::TYPE_PROPERTY, 
Highlighter::TYPE_NOTYPE )
+               );
+       }
+
 }
diff --git a/tests/phpunit/includes/NamespaceExaminerTest.php 
b/tests/phpunit/includes/NamespaceExaminerTest.php
index 20add1a..921e767 100644
--- a/tests/phpunit/includes/NamespaceExaminerTest.php
+++ b/tests/phpunit/includes/NamespaceExaminerTest.php
@@ -23,11 +23,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
diff --git a/tests/phpunit/includes/SubobjectTest.php 
b/tests/phpunit/includes/SubobjectTest.php
index e98f6eb..947921b 100644
--- a/tests/phpunit/includes/SubobjectTest.php
+++ b/tests/phpunit/includes/SubobjectTest.php
@@ -3,9 +3,9 @@
 namespace SMW\Test;
 
 use SMW\DataValueFactory;
+use SMW\DIProperty;
 use SMW\Subobject;
 
-use SMWDIProperty;
 use SMWDIBlob;
 use Title;
 
@@ -27,17 +27,15 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
- * @ingroup Test
  *
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
 /**
- * Tests for the Subobject class
  * @covers \SMW\Subobject
  *
  * @ingroup Test
@@ -128,7 +126,8 @@
 
                $instance = $this->getInstance( $this->getTitle() );
 
-               $this->assertInstanceOf( '\SMWContainerSemanticData',
+               $this->assertInstanceOf(
+                       '\SMWContainerSemanticData',
                        $instance->setSemanticData( $this->getRandomString() )
                );
                $this->assertEmpty( $instance->setSemanticData( '' ) );
@@ -166,7 +165,7 @@
        public function testGetProperty( array $test ) {
 
                $subobject = $this->getInstance( $this->getTitle(), 
$test['identifier'] );
-               $this->assertInstanceOf( '\SMWDIProperty', 
$subobject->getProperty() );
+               $this->assertInstanceOf( '\SMW\DIProperty', 
$subobject->getProperty() );
 
        }
 
@@ -191,7 +190,7 @@
                }
 
                $this->assertCount( $expected['errors'], 
$subobject->getErrors(), $info['msg'] );
-               $this->assertInstanceOf( 'SMWSemanticData', 
$subobject->getSemanticData(), $info['msg'] );
+               $this->assertInstanceOf( '\SMW\SemanticData', 
$subobject->getSemanticData(), $info['msg'] );
                $this->assertSemanticData( $subobject->getSemanticData(), 
$expected );
 
        }
@@ -204,56 +203,27 @@
         *
         * @param array $test
         * @param array $expected
-        * @param array $info
         */
        public function testDataValueExaminer( array $test, array $expected ) {
 
+               $property  = $this->newMockObject( array(
+                       'findPropertyTypeID' => $test['property']['typeId'],
+                       'getKey'             => $test['property']['key'],
+                       'getLabel'           => $test['property']['label'],
+               ) )->getMockDIProperty();
+
+               $dataValue = $this->newMockObject( array(
+                       'DataValueType' => $test['dataValue']['type'],
+                       'getDataItem'   => $test['dataValue']['dataItem'],
+                       'getProperty'   => $property,
+                       'isValid'       => true,
+               ) )->getMockDataValue();
+
                $subobject = $this->getInstance( $this->getTitle(), 
$this->getRandomString() );
-
-               // Mock Property object
-               $property = $this->getMockBuilder( $test['property']['DI'] )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $property->expects( $this->any() )
-                       ->method( 'findPropertyTypeID' )
-                       ->will( $this->returnValue( $test['property']['typeId'] 
)
-               );
-
-               $property->expects( $this->any() )
-                       ->method( 'getKey' )
-                       ->will( $this->returnValue( $test['property']['key'] )
-               );
-
-               $property->expects( $this->any() )
-                       ->method( 'getLabel' )
-                       ->will( $this->returnValue( $test['property']['label'] )
-               );
-
-               // Mock DataValue object
-               $dataValue = $this->getMockBuilder( $test['dataValue']['type'] )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $dataValue->expects( $this->any() )
-                       ->method( 'getProperty' )
-                       ->will( $this->returnValue( $property )
-               );
-
-               $dataValue->expects( $this->any() )
-                       ->method( 'isValid' )
-                       ->will( $this->returnValue( true )
-               );
-
-               $dataValue->expects( $this->any() )
-                       ->method( 'getDataItem' )
-                       ->will( $this->returnValue( 
$test['dataValue']['dataItem'] )
-               );
-
                $subobject->addPropertyValue( $dataValue );
 
                $this->assertCount( $expected['errors'], 
$subobject->getErrors() );
-               $this->assertInstanceOf( 'SMWSemanticData', 
$subobject->getSemanticData() );
+               $this->assertInstanceOf( '\SMW\SemanticData', 
$subobject->getSemanticData() );
                $this->assertSemanticData( $subobject->getSemanticData(), 
$expected );
 
        }
@@ -268,6 +238,7 @@
        public function testAddPropertyValueStringException() {
 
                $this->setExpectedException( 
'\SMW\InvalidSemanticDataException' );
+
                $subobject = new Subobject(  $this->getTitle() );
                $subobject->addPropertyValue( $this->getDataValue( 'Foo', 'Bar' 
) );
 
@@ -318,7 +289,7 @@
         * @return array
         */
        public function getDataProvider() {
-               $diPropertyError = new SMWDIProperty( SMWDIProperty::TYPE_ERROR 
);
+               $diPropertyError = new DIProperty( DIProperty::TYPE_ERROR );
                return array(
 
                        // #0
diff --git a/tests/phpunit/includes/utilities/ArrayAccessorTest.php 
b/tests/phpunit/includes/utilities/ArrayAccessorTest.php
index 7c0c77d..e1fbccd 100644
--- a/tests/phpunit/includes/utilities/ArrayAccessorTest.php
+++ b/tests/phpunit/includes/utilities/ArrayAccessorTest.php
@@ -22,11 +22,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
  * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 
diff --git a/tests/phpunit/includes/utilities/ProfilerTest.php 
b/tests/phpunit/includes/utilities/ProfilerTest.php
index 151c041..3c1ba73 100644
--- a/tests/phpunit/includes/utilities/ProfilerTest.php
+++ b/tests/phpunit/includes/utilities/ProfilerTest.php
@@ -24,11 +24,11 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @since 1.9
- *
  * @file
  *
  * @license GNU GPL v2+
+ * @since   1.9
+ *
  * @author mwjames
  */
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I298f6b097769d62d34ac0633b6e04c3ed3c2d1d6
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