Example #1
0
 public function testConvertMediaItems()
 {
     $xml = '<entry xmlns="http://www.w3.org/2005/Atom">
           <content type="application/xml">
             <mediaItem xmlns="http://ns.opensocial.org/2008/opensocial">
               <id>11223344</id>
               <thumbnailUrl>http://pages.example.org/images/11223344-tn.png</thumbnailUrl>
               <mimeType>image/png</mimeType>
               <type>image</type>
               <url>http://pages.example.org/images/11223344.png</url>
               <albumId>44332211</albumId>
             </mediaItem>
           </content>
           <title/>
           <updated>2003-12-13T18:30:02Z</updated>
           <author><url>example.org:55443322</url></author>
           <id>urn:guid:example.org:11223344</id>
         </entry>';
     $mediaItem = $this->inputAtomConverter->convertMediaItems($xml);
     $this->assertEquals('11223344', $mediaItem['id']);
     $this->assertEquals('http://pages.example.org/images/11223344-tn.png', $mediaItem['thumbnailUrl']);
     $this->assertEquals('44332211', $mediaItem['albumId']);
     $this->assertEquals('http://pages.example.org/images/11223344.png', $mediaItem['url']);
     $this->assertEquals('image/png', $mediaItem['mimeType']);
 }
 /**
  * Tests InputAtomConverter->convertPeople()
  */
 public function testConvertPeople()
 {
     $this->setExpectedException(Exception);
     $this->InputAtomConverter->convertPeople('');
 }
 private function decodeRequests($requestParam, $requestType, $format = 'json')
 {
     if (empty($requestParam)) {
         return null;
     }
     switch ($format) {
         case 'json':
             $inputConverter = new InputJsonConverter();
             break;
         case 'atom':
             $inputConverter = new InputAtomConverter();
             break;
         default:
             throw new Exception("Invalid or unsupported input format");
             break;
     }
     switch ($requestType) {
         case 'people':
             $ret = $inputConverter->convertPeople($requestParam);
             break;
         case 'activities':
             $ret = $inputConverter->convertActivities($requestParam);
             break;
         case 'messages':
             $ret = $inputConverter->convertMessages($requestParam);
             break;
         case 'appdata':
             $ret = $inputConverter->convertAppData($requestParam);
             break;
         case 'jsonbatch':
             // this type is only used by the internal json batch format
             if ($format != 'json') {
                 throw new Exception("the json batch only supports the json input format");
             }
             $ret = $inputConverter->convertJsonBatch($requestParam);
             break;
             //TODO add 'groups' and 'messages' here
         //TODO add 'groups' and 'messages' here
         default:
             throw new Exception("Unsupported REST call");
             break;
     }
     return $ret;
 }