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

Change subject: Implemented stubbing in QueryEntity
......................................................................


Implemented stubbing in QueryEntity

Change-Id: Iea6fe41bcf6dc1b5e5437dfae5d5152df91e1df6
---
M Tests/Phpunit/Wikibase/Query/QueryEntityTest.php
M src/Wikibase/Query/QueryEntity.php
2 files changed, 39 insertions(+), 54 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Wikibase/Query/QueryEntityTest.php 
b/Tests/Phpunit/Wikibase/Query/QueryEntityTest.php
index 73a5782..8c070ad 100644
--- a/Tests/Phpunit/Wikibase/Query/QueryEntityTest.php
+++ b/Tests/Phpunit/Wikibase/Query/QueryEntityTest.php
@@ -52,34 +52,18 @@
                $this->assertTrue( true );
        }
 
-//     public function testStubDoesNotMessThingsUp() {
-//             $queryEntity = $this->getNewSimpleEntity();
-//
-//             $query = $this->newQuery();
-//
-//             $queryEntity->setQuery( $query );
-//
-//             $queryEntity->stub();
-//             $obtainedQuery = $queryEntity->getQuery();
-//
-//             $this->assertInstanceOf( 'Ask\Language\Query', $obtainedQuery );
-//             $this->assertEquals( $query, $obtainedQuery );
-//     }
-//
-//     public function testArraySerlialzationRoundtripWithQuery() {
-//             $queryEntity = $this->getNewSimpleEntity();
-//
-//             $query = $this->newQuery();
-//
-//             $queryEntity->setQuery( $query );
-//
-//             $serialization = $queryEntity->toArray();
-//
-//             $newQueryEntity = $queryEntity::newFromArray( $serialization );
-//
-//             $queryEntity->stub();
-//
-//             $this->assertEquals( $queryEntity, $newQueryEntity );
-//     }
+       public function testStubDoesNotMessThingsUp() {
+               $queryEntity = $this->getNewSimpleEntity();
+
+               $query = $this->newQuery();
+
+               $queryEntity->setQuery( $query );
+
+               $queryEntity->stub();
+               $obtainedQuery = $queryEntity->getQuery();
+
+               $this->assertInstanceOf( 'Ask\Language\Query', $obtainedQuery );
+               $this->assertEquals( $query, $obtainedQuery );
+       }
 
 }
diff --git a/src/Wikibase/Query/QueryEntity.php 
b/src/Wikibase/Query/QueryEntity.php
index ea134d5..abb3e1c 100644
--- a/src/Wikibase/Query/QueryEntity.php
+++ b/src/Wikibase/Query/QueryEntity.php
@@ -5,7 +5,6 @@
 use Ask\DeserializerFactory;
 use Ask\Language\Query;
 use Ask\SerializerFactory;
-use InvalidArgumentException;
 use MWException;
 use RuntimeException;
 use Wikibase\Entity;
@@ -49,6 +48,8 @@
         * @throws RuntimeException
         */
        public function getQuery() {
+               $this->unstubQuery();
+
                return $this->query;
        }
 
@@ -74,29 +75,29 @@
                return QueryEntity::ENTITY_TYPE;
        }
 
-//     /**
-//      * @see Entity::stub
-//      */
-//     public function stub() {
-//             parent::stub();
-//
-//             if ( $this->query !== null ) {
-//                     $serializerFactory = new SerializerFactory();
-//
-//                     $this->data['query'] = 
$serializerFactory->newQuerySerializer()->serialize( $this->query );
-//                     $this->query = null;
-//             }
-//     }
-//
-//     /**
-//      * @see Entity::unstubQuery
-//      */
-//     protected function unstubQuery() {
-//             if( $this->query === null && array_key_exists( 'query', 
$this->data ) ) {
-//                     $deserializerFactory = new DeserializerFactory( 
WikibaseRepo::getDefaultInstance()->getDataValueFactory() );
-//
-//                     $this->query = 
$deserializerFactory->newQueryDeSerializer()->deserialize( $this->data['query'] 
);
-//             }
-//     }
+       /**
+        * @see Entity::stub
+        */
+       public function stub() {
+               parent::stub();
+
+               if ( $this->query !== null ) {
+                       $serializerFactory = new SerializerFactory();
+
+                       $this->data['query'] = 
$serializerFactory->newQuerySerializer()->serialize( $this->query );
+                       $this->query = null;
+               }
+       }
+
+       /**
+        * @see Entity::unstubQuery
+        */
+       protected function unstubQuery() {
+               if( $this->query === null && array_key_exists( 'query', 
$this->data ) ) {
+                       $deserializerFactory = new DeserializerFactory( 
WikibaseRepo::getDefaultInstance()->getDataValueFactory() );
+
+                       $this->query = 
$deserializerFactory->newQueryDeSerializer()->deserialize( $this->data['query'] 
);
+               }
+       }
 
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iea6fe41bcf6dc1b5e5437dfae5d5152df91e1df6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQuery
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to