You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by bh...@apache.org on 2010/11/04 00:58:08 UTC
svn commit: r1030766 - in /shindig/trunk/php:
src/gadgets/templates/DataPipelining.php test/gadgets/DataPipeliningTest.php
Author: bhofmann
Date: Wed Nov 3 23:58:08 2010
New Revision: 1030766
URL: http://svn.apache.org/viewvc?rev=1030766&view=rev
Log:
SHINDIG-1462: added support for os:PersonAppDataRequest, fixed os:ViewerRequest
Added:
shindig/trunk/php/test/gadgets/DataPipeliningTest.php
Modified:
shindig/trunk/php/src/gadgets/templates/DataPipelining.php
Modified: shindig/trunk/php/src/gadgets/templates/DataPipelining.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/templates/DataPipelining.php?rev=1030766&r1=1030765&r2=1030766&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/DataPipelining.php (original)
+++ shindig/trunk/php/src/gadgets/templates/DataPipelining.php Wed Nov 3 23:58:08 2010
@@ -34,7 +34,7 @@ class DataPipelining {
$dataTags = $viewNode->getElementsByTagName('*');
if ($dataTags->length > 0) {
$dataPipeliningTags = array();
- $namespaceErrorTags = array('httprequest', 'datarequest', 'peoplerequest', 'viewerrequest', 'ownerrequest', 'activitiesrequest');
+ $namespaceErrorTags = array('httprequest', 'datarequest', 'peoplerequest', 'personappdatarequest', 'viewerrequest', 'ownerrequest', 'activitiesrequest');
foreach ($dataTags as $dataTag) {
$tag = array();
$tag['type'] = $dataTag->tagName;
@@ -58,12 +58,16 @@ class DataPipelining {
$tag['type'] = 'os:DataRequest';
$tag['method'] = 'people.get';
break;
+ case 'os:PersonAppDataRequest':
+ $tag['type'] = 'os:DataRequest';
+ $tag['method'] = 'appdata.get';
+ break;
case 'os:ViewerRequest':
case 'os:OwnerRequest':
- $tag['type'] = 'os:DataRequest';
$tag['method'] = 'people.get';
- $tag['userId'] = $tag['type'] == 'osViewerRequest' ? '@viewer' : '@owner';
+ $tag['userId'] = $tag['type'] == 'os:ViewerRequest' ? '@viewer' : '@owner';
$tag['groupId'] = '@self';
+ $tag['type'] = 'os:DataRequest';
break;
case 'os:ActivitiesRequest':
$tag['type'] = 'os:DataRequest';
Added: shindig/trunk/php/test/gadgets/DataPipeliningTest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/gadgets/DataPipeliningTest.php?rev=1030766&view=auto
==============================================================================
--- shindig/trunk/php/test/gadgets/DataPipeliningTest.php (added)
+++ shindig/trunk/php/test/gadgets/DataPipeliningTest.php Wed Nov 3 23:58:08 2010
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ContainerConfig test case.
+ */
+class DataPipeliningTest extends PHPUnit_Framework_TestCase {
+ /**
+ * @var Gadget
+ */
+ private $viewNode = '<?xml version="1.0" encoding="UTF-8" ?>
+ <script xmlns:os="http://ns.opensocial.org/2008/markup" type="text/os-data">
+ <os:PeopleRequest key="viewer" userId="@viewer" groupId="@self"/>
+ <os:PeopleRequest key="viewerFriends" userId="@viewer" groupId="@friends" foo="bar"/>
+ <os:ViewerRequest />
+ <os:OwnerRequest />
+ <os:PersonAppDataRequest key="appdata" userId="@viewer" fields="field" />
+ <os:PersonAppDataRequest key="appdataFriends" userId="@viewer" groupId="@friends" fields="field" />
+ <os:ActivitiesRequest />
+ <os:HttpRequest href="http://example.com" />
+ </script>
+ ';
+
+ public function testParse() {
+ $doc = new DomDocument();
+ $doc->loadXml($this->viewNode);
+ $contentBlocks = $doc->getElementsByTagName('script');
+ $tags = array();
+ foreach ($contentBlocks as $content) {
+ $tags[] = DataPipelining::parse($content);
+ }
+ $this->assertEquals(1, count($tags));
+
+ $expected = array(
+ array(
+ 'type' => 'os:DataRequest',
+ 'key' => 'viewer',
+ 'userId' => '@viewer',
+ 'groupId' => '@self',
+ 'method' => 'people.get',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'key' => 'viewerFriends',
+ 'userId' => '@viewer',
+ 'groupId' => '@friends',
+ 'method' => 'people.get',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'method' => 'people.get',
+ 'userId' => '@viewer',
+ 'groupId' => '@self',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'method' => 'people.get',
+ 'userId' => '@owner',
+ 'groupId' => '@self',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'key' => 'appdata',
+ 'userId' => '@viewer',
+ 'fields' => 'field',
+ 'method' => 'appdata.get',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'key' => 'appdataFriends',
+ 'userId' => '@viewer',
+ 'groupId' => '@friends',
+ 'fields' => 'field',
+ 'method' => 'appdata.get',
+ ),
+ array(
+ 'type' => 'os:DataRequest',
+ 'method' => 'activities.get',
+ ),
+ array(
+ 'type' => 'os:HttpRequest',
+ 'href' => 'http://example.com',
+ ),
+ );
+
+ $this->assertEquals($expected, $tags[0]);
+
+ }
+}