public function testQueryResultSerializerOnMockOnDIWikiPageNonTitle()
 {
     $dataItem = $this->newMockBuilder()->newObject('DataItem', array('getDIType' => DataItem::TYPE_WIKIPAGE, 'getTitle' => null));
     $queryResult = $this->newMockBuilder()->newObject('QueryResult', array('getPrintRequests' => array(), 'getResults' => array($dataItem)));
     $instance = new QueryResultSerializer();
     $results = $instance->serialize($queryResult);
     $this->assertInternalType('array', $results);
     $this->assertEmpty($results['printrequests']);
     $this->assertEmpty($results['results']);
 }
示例#2
0
 /**
  * Initiates serialization of an object
  *
  * @since 1.9
  *
  * @param mixed $object
  *
  * @return array
  */
 public static function serialize($object)
 {
     $serializer = null;
     if ($object instanceof SemanticData) {
         $serializer = new SemanticDataSerializer();
     } elseif ($object instanceof QueryResult) {
         $serializer = new QueryResultSerializer();
     }
     if (!$serializer instanceof Serializer) {
         throw new OutOfBoundsException('For the object no serializer has been registered');
     }
     return $serializer->serialize($object);
 }