예제 #1
0
파일: RoleTest.php 프로젝트: seytar/psx
    public function testRole()
    {
        $laura = new Object();
        $laura->setObjectType('person');
        $laura->setDisplayName('Laura');
        $mark = new Object();
        $mark->setObjectType('person');
        $mark->setDisplayName('Mark');
        $members = new Collection();
        $members->add($laura);
        $members->add($mark);
        $role = new Role();
        $role->setDisplayName('My Work Group');
        $role->setMembers($members);
        $content = <<<JSON
  {
    "objectType": "role",
    "displayName": "My Work Group",
    "members": {
      "items": [
        {
          "objectType": "person",
          "displayName": "Laura"
        },
        {
          "objectType": "person",
          "displayName": "Mark"
        }
      ]
    }
  }
JSON;
        $this->assertRecordEqualsContent($role, $content);
        $this->assertEquals($members, $role->getMembers());
    }
예제 #2
0
    public function testPermission()
    {
        $file = new Object();
        $file->setObjectType('file');
        $file->setDisplayName('2Q2014 Sales Forecast.xls');
        $html = new Object();
        $html->setObjectType('inline-html');
        $html->setContent('<video ... />');
        $share = new Object();
        $share->setObjectType('service');
        $share->setDisplayName('My Sharing Service');
        $share->setUrl('http://example.net/share');
        $permission = new Permission();
        $permission->setDisplayName('Permission to Edit File: 2Q2014 Sales Forecast.xls');
        $permission->setScope($file);
        $content = <<<JSON
  {
    "objectType": "permission",
    "displayName": "Permission to Edit File: 2Q2014 Sales Forecast.xls",
    "scope": {
      "objectType": "file",
      "displayName": "2Q2014 Sales Forecast.xls"
    }
  }
JSON;
        $this->assertRecordEqualsContent($permission, $content);
        $this->assertEquals($file, $permission->getScope());
    }
예제 #3
0
파일: TaskTest.php 프로젝트: seytar/psx
    public function testTask()
    {
        $actor = new Object();
        $actor->setObjectType('person');
        $actor->setDisplayName('James');
        $object = new Object();
        $object->setObjectType('file');
        $object->setDisplayName('A specification');
        $object->setUrl('http://example.org/spec.html');
        $subTask = new Task();
        $subTask->setDisplayName('Foo task');
        $task = new Task();
        $task->setDisplayName('James needs to read the spec');
        $task->setBy(new DateTime('2012-12-12T12:12:12Z'));
        $task->setVerb('read');
        $task->setActor($actor);
        $task->setObject($object);
        $task->setRequired(true);
        $task->setPrerequisites(array($subTask));
        $task->setSupersedes(array($subTask));
        $content = <<<JSON
{
  "actor": {
    "objectType": "person",
    "displayName": "James"
  },
  "by": "2012-12-12T12:12:12Z",
  "object": {
    "objectType": "file",
    "displayName": "A specification",
    "url": "http://example.org/spec.html"
  },
  "prerequisites": [{
      "objectType": "task",
      "displayName": "Foo task"
    }],
  "required": true,
  "supersedes": [{
      "objectType": "task",
      "displayName": "Foo task"
    }],
  "verb": "read",
  "objectType": "task",
  "displayName": "James needs to read the spec"
}
JSON;
        $this->assertRecordEqualsContent($task, $content);
        $this->assertEquals($actor, $task->getActor());
        $this->assertEquals(new DateTime('2012-12-12T12:12:12Z'), $task->getBy());
        $this->assertEquals($object, $task->getObject());
        $this->assertEquals(array($subTask), $task->getPrerequisites());
        $this->assertEquals(true, $task->getRequired());
        $this->assertEquals(array($subTask), $task->getSupersedes());
        $this->assertEquals('read', $task->getVerb());
    }
예제 #4
0
파일: BinaryTest.php 프로젝트: seytar/psx
    public function testBinary()
    {
        $stream = new Object();
        $stream->setUrl('http://example.org/my_binary.mp3');
        $binary = new Binary();
        $binary->setCompression('deflate');
        $binary->setData('dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=');
        $binary->setFileUrl('foo.txt');
        $binary->setLength(25);
        $binary->setMd5('827ae7e1ab45e4dd591d087c741e5770');
        $binary->setMimeType('text/plain');
        $object = new Object();
        $object->setObjectType('note');
        $object->setDisplayName('A note with a binary attachment');
        $object->setAttachments(array($binary));
        $content = <<<JSON
  {
    "objectType": "note",
    "displayName": "A note with a binary attachment",
    "attachments": [
\t  {
\t    "objectType": "binary",
\t    "compression": "deflate",
\t    "data": "dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=",
\t    "fileUrl": "foo.txt",
\t    "length": 25,
\t    "md5": "827ae7e1ab45e4dd591d087c741e5770",
\t    "mimeType": "text/plain"
\t  }
    ]
  }
JSON;
        $this->assertRecordEqualsContent($object, $content);
        $this->assertEquals('deflate', $binary->getCompression());
        $this->assertEquals('dGhpcyBpcyB1bmNvbXByZXNzZWQgZGF0YQo=', $binary->getData());
        $this->assertEquals('foo.txt', $binary->getFileUrl());
        $this->assertEquals(25, $binary->getLength());
        $this->assertEquals('827ae7e1ab45e4dd591d087c741e5770', $binary->getMd5());
        $this->assertEquals('text/plain', $binary->getMimeType());
    }
예제 #5
0
파일: AudioTest.php 프로젝트: seytar/psx
    public function testAudio()
    {
        $stream = new Object();
        $stream->setUrl('http://example.org/my_audio.mp3');
        $audio = new Audio();
        $audio->setDisplayName('Cute little kittens');
        $audio->setEmbedCode('<audio controls=\'controls\'>...</audio>');
        $audio->setStream($stream);
        $content = <<<JSON
  {
    "objectType": "audio",
    "displayName": "Cute little kittens",
    "embedCode": "<audio controls='controls'>...</audio>",
    "stream": {
      "url": "http://example.org/my_audio.mp3"
    }
  }
JSON;
        $this->assertRecordEqualsContent($audio, $content);
        $this->assertEquals('<audio controls=\'controls\'>...</audio>', $audio->getEmbedCode());
        $this->assertEquals($stream, $audio->getStream());
    }
예제 #6
0
파일: VideoTest.php 프로젝트: seytar/psx
    public function testVideo()
    {
        $stream = new Object();
        $stream->setUrl('http://example.org/my_video.mpg');
        $video = new Video();
        $video->setDisplayName('Cute little kittens');
        $video->setEmbedCode('<video width=\'320\' height=\'240\' controls=\'controls\'>...</video>');
        $video->setStream($stream);
        $content = <<<JSON
  {
    "objectType": "video",
    "displayName": "Cute little kittens",
    "embedCode": "<video width='320' height='240' controls='controls'>...</video>",
    "stream": {
      "url": "http://example.org/my_video.mpg"
    }
  }
JSON;
        $this->assertRecordEqualsContent($video, $content);
        $this->assertEquals('video', $video->getObjectType());
        $this->assertEquals('Cute little kittens', $video->getDisplayName());
        $this->assertEquals('<video width=\'320\' height=\'240\' controls=\'controls\'>...</video>', $video->getEmbedCode());
        $this->assertEquals('http://example.org/my_video.mpg', $video->getStream()->getUrl());
    }
예제 #7
0
 public function getComplexRecord()
 {
     $actor = new ActivityStream\Object();
     $actor->setUrl('http://example.org/martin');
     $actor->setObjectType('person');
     $actor->setId('tag:example.org,2011:martin');
     $actor->setDisplayName('Martin Smith');
     $object = new ActivityStream\Object();
     $object->setUrl('http://example.org/blog/2011/02/entry');
     $object->setId('tag:example.org,2011:abc123/xyz');
     $target = new ActivityStream\Object();
     $target->setUrl('http://example.org/blog/');
     $target->setObjectType('blog');
     $target->setId('tag:example.org,2011:abc123');
     $target->setDisplayName('Martin\'s Blog');
     $activity = new ActivityStream\ObjectType\Activity();
     $activity->setPublished(new DateTime('2011-02-10T15:04:55Z'));
     $activity->setActor($actor);
     $activity->setVerb('post');
     $activity->setObject($object);
     $activity->setTarget($target);
     return $activity;
 }
예제 #8
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->addLink($this->getUrl(), 'alternate', 'text/html');
             $entry->setContent($this->text, 'html');
             return $entry;
             break;
         case WriterInterface::JAS:
             $image = new ActivityStream\MediaLink();
             $image->setUrl($this->authorThumbnailUrl);
             $actor = new ActivityStream\Object();
             $actor->setObjectType('person');
             $actor->setDisplayName($this->authorName);
             $actor->setUrl($this->authorProfileUrl);
             $actor->setImage($image);
             $object = new ActivityStream\Object();
             $object->setObjectType('article');
             $object->setId('urn:uuid:' . $this->globalId);
             $object->setDisplayName($this->title);
             $object->setUrl($this->getUrl());
             $object->setPublished($this->getDate());
             $object->setContent($this->text);
             $activity = new ActivityStream\Activity();
             $activity->setActor($actor);
             $activity->setVerb('post');
             $activity->setObject($object);
             return $activity;
             break;
         default:
             return parent::export($result);
             break;
     }
 }
예제 #9
0
파일: ActivityTest.php 프로젝트: seytar/psx
    public function testComplexActivity()
    {
        $generator = new Object();
        $generator->setUrl('http://example.org/activities-app');
        $provider = new Object();
        $provider->setUrl('http://example.org/activity-stream');
        $image = new Object();
        $image->setUrl('http://example.org/martin/image');
        $image->setMediaType('image/jpeg');
        $image->setWidth(250);
        $image->setHeight(250);
        $actor = new Object();
        $actor->setUrl('http://example.org/martin');
        $actor->setObjectType('person');
        $actor->setId('urn:example:person:martin');
        $actor->setImage($image);
        $actor->setDisplayName('Martin Smith');
        $image = new Object();
        $image->setUrl('http://example.org/album/my_fluffy_cat_thumb.jpg');
        $image->setMediaType('image/jpeg');
        $image->setWidth(250);
        $image->setHeight(250);
        $objectType = new Object();
        $objectType->setId('http://example.org/Photo');
        $objectType->setDisplayName('Photo');
        $object = new Object();
        $object->setUrl('http://example.org/album/my_fluffy_cat.jpg');
        $object->setObjectType($objectType);
        $object->setId('urn:example:album:abc123/my_fluffy_cat');
        $object->setImage($image);
        $image = new Object();
        $image->setUrl('http://example.org/album/thumbnail.jpg');
        $image->setMediaType('image/jpeg');
        $image->setWidth(250);
        $image->setHeight(250);
        $objectType = new Object();
        $objectType->setId('http://example.org/PhotoAlbum');
        $objectType->setDisplayName('Photo-Album');
        $displayName = new \stdClass();
        $displayName->en = 'Martin\'s Photo Album';
        $displayName->ga = 'Grianghraif Mairtin';
        $target = new Object();
        $target->setUrl('http://example.org/album/');
        $target->setObjectType($objectType);
        $target->setId('urn:example.org:album:abc123');
        $target->setDisplayName($displayName);
        $target->setImage($image);
        $activity = new Activity();
        $activity->setVerb('post');
        $activity->setLanguage('en');
        $activity->setPublished(new DateTime('2011-02-10T15:04:55Z'));
        $activity->setGenerator('http://example.org/activities-app');
        $activity->setProvider('http://example.org/activity-stream');
        $displayName = new \stdClass();
        $displayName->en = 'Martin posted a new video to his album.';
        $displayName->ga = 'Martin phost le fisean nua a albam.';
        $activity->setDisplayName($displayName);
        $activity->setActor($actor);
        $activity->setObject($object);
        $activity->setTarget($target);
        $collection = new Collection();
        $collection->setTotalItems(1);
        $collection->add($activity);
        $content = <<<JSON
{
  "totalItems": 1,
  "items": [{
      "verb": "post",
      "language": "en",
      "published": "2011-02-10T15:04:55Z",
      "generator": "http://example.org/activities-app",
      "provider": "http://example.org/activity-stream",
      "displayName": {
        "en": "Martin posted a new video to his album.",
        "ga": "Martin phost le fisean nua a albam."
      },
      "actor": {
        "objectType": "person",
        "id": "urn:example:person:martin",
        "displayName": "Martin Smith",
        "url": "http://example.org/martin",
        "image": {
          "url": "http://example.org/martin/image",
          "mediaType": "image/jpeg",
          "width": 250,
          "height": 250
        }
      },
      "object": {
        "objectType": {
          "id": "http://example.org/Photo",
          "displayName": "Photo"
        },
        "id": "urn:example:album:abc123/my_fluffy_cat",
        "url": "http://example.org/album/my_fluffy_cat.jpg",
        "image": {
          "url": "http://example.org/album/my_fluffy_cat_thumb.jpg",
          "mediaType": "image/jpeg",
          "width": 250,
          "height": 250
        }
      },
      "target": {
        "objectType": {
          "id": "http://example.org/PhotoAlbum",
          "displayName": "Photo-Album"
        },
        "id": "urn:example.org:album:abc123",
        "url": "http://example.org/album/",
        "displayName": {
          "en": "Martin's Photo Album",
          "ga": "Grianghraif Mairtin"
        },
        "image": {
          "url": "http://example.org/album/thumbnail.jpg",
          "mediaType": "image/jpeg",
          "width": 250,
          "height": 250
        }
      }
    }]
}
JSON;
        $this->assertRecordEqualsContent($collection, $content);
    }
예제 #10
0
    public function testStream()
    {
        $items = array();
        $author = new Object();
        $author->setObjectType('person');
        $author->setId('12345678-8f0a-1028-xxxz-db07163b51b2');
        $author->setDisplayName('Joe Blogs');
        $item = new Object();
        $item->setContent('This was my first comment');
        $item->setAuthor($author);
        $item->setUpdated(new DateTime('2011-11-21T15:13:59+00:00'));
        $item->setId('f8f0e93f-e462-4ede-92cc-f6e8a1b7eb36');
        $items[] = $item;
        $author = new Object();
        $author->setObjectType('person');
        $author->setId('12345678-8f0a-1028-xxxy-db07163b51b2');
        $author->setDisplayName('Jane Doe');
        $item = new Object();
        $item->setContent('This was another comment');
        $item->setAuthor($author);
        $item->setUpdated(new DateTime('2011-11-21T15:14:06+00:00'));
        $item->setId('5369ea82-d791-46cb-a87a-3696ff90d8f3');
        $items[] = $item;
        $replies = new Collection();
        $replies->setItems($items);
        $replies->setTotalItems(0);
        $author = new Object();
        $author->setId('12345678-8f0a-1028-xxxx-db07163b51b2');
        $author->setDisplayName('Joseph Bloggs');
        $target = new Object();
        $target->setSummary('Top App Entry');
        $target->setReplies($replies);
        $target->setObjectType('note');
        $target->setAuthor($author);
        $target->setUpdated(new DateTime('2011-11-21T15:08:44+00:00'));
        $target->setId('87d7a7fb-af22-403b-ab0d-d101d9caac4f');
        $target->setDisplayName('Joseph Bloggs');
        $target->setPublished(new DateTime('2011-11-21T15:08:44+00:00'));
        $target->setUrl('http://www.example.org/topapp/1028-xxxx-db07163b51b2');
        $provider = new Object();
        $provider->setId('http://www.ibm.com/xmlns/prod/sn');
        $provider->setDisplayName('IBM Connections - News Service');
        $provider->setUrl('http://www.example.org/news');
        $image = new Object();
        $image->setUrl('http://www.example.org/topapp/images/icon.png');
        $generator = new Object();
        $generator->setImage($image);
        $generator->setId('topapp');
        $generator->setDisplayName('Top Application');
        $generator->setUrl('http://www.example.org/topapp');
        $actor = new Object();
        $actor->setId('12345678-8f0a-1028-xxxx-db07163b51b2');
        $actor->setDisplayName('Joseph Bloggs');
        $author = new Object();
        $author->setId('12345678-8f0a-1028-xxxx-db07163b51b2');
        $author->setDisplayName('Joseph Bloggs');
        $object = new Object();
        $object->setSummary('This was my first comment');
        $object->setObjectType('comment');
        $object->setAuthor($author);
        $object->setId('5369ea82-d791-46cb-a87a-3696ff90d8f3');
        $object->setUrl('http://www.example.org/topapp/1028-xxxx-db07163b51b2/comments/1');
        $activity = new Activity();
        $activity->setPublished(new DateTime('2011-11-21T15:14:06+00:00'));
        $activity->setUrl('http://www.example.org/connections/opensocial/rest/activitystreams/@me/@all/@all/86c62a05-61de-4658-97a7-16e7ccf72e78');
        $activity->setTarget($target);
        $activity->setProvider($provider);
        $activity->setGenerator($generator);
        $activity->setActor($actor);
        $activity->setTitle('Joseph Bloggs commented on their own Top App entry.');
        $activity->setContent('<span class="vcard"><a class="fn url" title="This is a link to the profile of Joseph Bloggs." href="http://www.example.org/profiles/html/profileView.do?userid=12345678-8f0a-1028-xxxx-db07163b51b2"><span class="photo" src="http://www.example.org/profiles/photo.do?userid=12345678-8f0a-1028-xxxx-db07163b51b2" alt="This is a photo of Joseph Bloggs." style="display : none"></span>Joseph Bloggs</a><span class="x-lconn-userid" style="display : none">12345678-8f0a-1028-xxxx-db07163b51b2</span></span> commented on their own Top App entry.');
        $activity->setId('urn:lsid:ibm.com:activitystreams:86c62a05-61de-4658-97a7-16e7ccf72e78');
        $activity->setUpdated(new DateTime('2011-11-21T15:14:07+00:00'));
        $activity->setObject($object);
        $activity->setVerb('post');
        $collection = new Collection();
        $collection->setStartIndex(0);
        $collection->setTotalItems(1);
        $collection->setItemsPerPage(1);
        $collection->setItems([$activity]);
        $content = <<<JSON
{
    "startIndex": 0,
    "totalItems": 1,
    "itemsPerPage": 1,
    "items": [
        {
        "published": "2011-11-21T15:14:06Z",
        "url": "http://www.example.org/connections/opensocial/rest/activitystreams/@me/@all/@all/86c62a05-61de-4658-97a7-16e7ccf72e78",
        "target": {
            "summary": "Top App Entry",
            "replies": {
                "items": [{
                    "content": "This was my first comment",
                    "author": {
                        "objectType": "person",
                        "id": "12345678-8f0a-1028-xxxz-db07163b51b2",
                        "displayName": "Joe Blogs"
                    },
                    "updated": "2011-11-21T15:13:59Z",
                    "id": "f8f0e93f-e462-4ede-92cc-f6e8a1b7eb36"
                 },
                 {
                    "content": "This was another comment",
                    "author": {
                        "objectType": "person",
                        "id": "12345678-8f0a-1028-xxxy-db07163b51b2",
                        "displayName": "Jane Doe"
                    },
                    "updated": "2011-11-21T15:14:06Z",
                    "id": "5369ea82-d791-46cb-a87a-3696ff90d8f3"
                 }],
                "totalItems": 0
            },
            "objectType": "note",
            "author": {
                "id": "12345678-8f0a-1028-xxxx-db07163b51b2",
                "displayName": "Joseph Bloggs"
            },
            "updated": "2011-11-21T15:08:44Z",
            "id": "87d7a7fb-af22-403b-ab0d-d101d9caac4f",
            "displayName": "Joseph Bloggs",
            "published": "2011-11-21T15:08:44Z",
            "url": "http://www.example.org/topapp/1028-xxxx-db07163b51b2"
        },
        "provider": {
            "id": "http://www.ibm.com/xmlns/prod/sn",
            "displayName": "IBM Connections - News Service",
            "url": "http://www.example.org/news"
        },
        "generator": {
            "image": {
                "url": "http://www.example.org/topapp/images/icon.png"
            },
            "id": "topapp",
            "displayName": "Top Application",
            "url": "http://www.example.org/topapp"
        },
        "actor": {
            "id": "12345678-8f0a-1028-xxxx-db07163b51b2",
            "displayName": "Joseph Bloggs"
        },
        "title": "Joseph Bloggs commented on their own Top App entry.",
        "content": "<span class=\\"vcard\\"><a class=\\"fn url\\" title=\\"This is a link to the profile of Joseph Bloggs.\\" href=\\"http://www.example.org/profiles/html/profileView.do?userid=12345678-8f0a-1028-xxxx-db07163b51b2\\"><span class=\\"photo\\" src=\\"http://www.example.org/profiles/photo.do?userid=12345678-8f0a-1028-xxxx-db07163b51b2\\" alt=\\"This is a photo of Joseph Bloggs.\\" style=\\"display : none\\"></span>Joseph Bloggs</a><span class=\\"x-lconn-userid\\" style=\\"display : none\\">12345678-8f0a-1028-xxxx-db07163b51b2</span></span> commented on their own Top App entry.",
        "id": "urn:lsid:ibm.com:activitystreams:86c62a05-61de-4658-97a7-16e7ccf72e78",
        "updated": "2011-11-21T15:14:07Z",
        "object": {
            "summary": "This was my first comment",
            "objectType": "comment",
            "author": {
                "id": "12345678-8f0a-1028-xxxx-db07163b51b2",
                "displayName": "Joseph Bloggs"
            },
            "id": "5369ea82-d791-46cb-a87a-3696ff90d8f3",
            "url": "http://www.example.org/topapp/1028-xxxx-db07163b51b2/comments/1"
        },
        "verb": "post"
    }]
}
JSON;
        $this->assertRecordEqualsContent($collection, $content);
    }
예제 #11
0
    public function testCollection()
    {
        $items = array();
        $item = new Object();
        $item->setContent('This was my first comment');
        $item->setUpdated(new DateTime('2011-11-21T15:13:59+00:00'));
        $item->setId('f8f0e93f-e462-4ede-92cc-f6e8a1b7eb36');
        $items[] = $item;
        $item = new Object();
        $item->setContent('This was another comment');
        $item->setUpdated(new DateTime('2011-11-21T15:14:06+00:00'));
        $item->setId('5369ea82-d791-46cb-a87a-3696ff90d8f3');
        $items[] = $item;
        $collection = new Collection();
        $collection->setItems($items);
        $collection->setTotalItems(4);
        $collection->setItemsAfter(new DateTime('2011-11-21T15:13:59+00:00'));
        $collection->setItemsBefore(new DateTime('2011-11-21T15:13:59+00:00'));
        $collection->setItemsPerPage(2);
        $collection->setStartIndex(0);
        $collection->setFirst('urn:foo:page:1');
        $collection->setLast('urn:foo:page:4');
        $collection->setPrev('urn:foo:page:2');
        $collection->setNext('urn:foo:page:4');
        $collection->setCurrent('urn:foo:page:3');
        $collection->setSelf('urn:foo:page:3');
        $content = <<<JSON
  {
    "totalItems": 4,
    "items": [{
    \t"id": "f8f0e93f-e462-4ede-92cc-f6e8a1b7eb36",
    \t"content": "This was my first comment",
    \t"updated": "2011-11-21T15:13:59Z"
    },{
    \t"id": "5369ea82-d791-46cb-a87a-3696ff90d8f3",
    \t"content": "This was another comment",
    \t"updated": "2011-11-21T15:14:06Z"
    }],
    "itemsAfter": "2011-11-21T15:13:59Z",
    "itemsBefore": "2011-11-21T15:13:59Z",
    "itemsPerPage": 2,
    "startIndex": 0,
    "first": "urn:foo:page:1",
    "last": "urn:foo:page:4",
    "prev": "urn:foo:page:2",
    "next": "urn:foo:page:4",
    "current": "urn:foo:page:3",
    "self": "urn:foo:page:3"
  }
JSON;
        $this->assertRecordEqualsContent($collection, $content);
        $this->assertEquals($items, $collection->getItems());
        $this->assertEquals(4, $collection->getTotalItems());
        $this->assertEquals(new DateTime('2011-11-21T15:13:59+00:00'), $collection->getItemsAfter());
        $this->assertEquals(new DateTime('2011-11-21T15:13:59+00:00'), $collection->getItemsBefore());
        $this->assertEquals(2, $collection->getItemsPerPage());
        $this->assertEquals(0, $collection->getStartIndex());
        $this->assertEquals('urn:foo:page:1', $collection->getFirst());
        $this->assertEquals('urn:foo:page:4', $collection->getLast());
        $this->assertEquals('urn:foo:page:2', $collection->getPrev());
        $this->assertEquals('urn:foo:page:4', $collection->getNext());
        $this->assertEquals('urn:foo:page:3', $collection->getCurrent());
        $this->assertEquals('urn:foo:page:3', $collection->getSelf());
    }
예제 #12
0
    public function testStream()
    {
        $image = new Object();
        $image->setHeight(32);
        $image->setWidth(32);
        $author = new Object();
        $author->setDisplayName('Internal TW Admin user');
        $author->setId('tw_admin');
        $author->setImage($image);
        $author->setObjectType('PERSON');
        $item = new Object();
        $item->setAuthor($author);
        $item->setContent('tagging Internal TW Admin user user');
        $item->setObjectType('COMMENT');
        $item->setPublished(new DateTime('2012-01-09T16:18:44+00:00'));
        $replies = new Collection();
        $replies->setItems([$item]);
        $actor = new Object();
        $actor->setId('tw_admin');
        $actor->setDisplayName('Internal TW Admin user');
        $actor->setObjectType('PERSON');
        $object = new Object();
        $object->setDisplayName('Task: Submit requisition');
        $object->setId('2078.3');
        $object->setObjectType('ibm.bpm.task');
        $activity = new Activity();
        $activity->setActor($actor);
        $activity->setContent('Internal TW Admin user completed the task titled Task: Submit requisition and associated with the Submit job requisition activity.');
        $activity->setObject($object);
        $activity->setPublished(new DateTime('2012-01-09T09:58:00+00:00'));
        $activity->setVerb('POST');
        $activity->setReplies($replies);
        $collection = new Collection();
        $collection->setTotalItems(1);
        $collection->setItems([$activity]);
        $content = <<<JSON
{
    "totalItems":1,
    "items":[
        {
            "actor":{
                "displayName":"Internal TW Admin user",
                "id":"tw_admin",
                "objectType":"PERSON"
            },
            "content":"Internal TW Admin user completed the task titled Task: Submit requisition and associated with the Submit job requisition activity.",
            "object":{
                "displayName":"Task: Submit requisition",
                "id":"2078.3",
                "objectType":"ibm.bpm.task"
            },
            "published":"2012-01-09T09:58:00Z",
            "verb":"POST",
            "replies":{
                "items":[
                    {
                        "author":{
                            "displayName":"Internal TW Admin user",
                            "id":"tw_admin",
                            "image":{
                                "height":32,
                                "width":32
                            },
                            "objectType":"PERSON"
                        },
                        "content":"tagging Internal TW Admin user user",
                        "objectType":"COMMENT",
                        "published":"2012-01-09T16:18:44Z"
                    }
                ]
            }
        }
    ]
}
JSON;
        $this->assertRecordEqualsContent($collection, $content);
    }
예제 #13
0
파일: EventTest.php 프로젝트: seytar/psx
    public function testEvent()
    {
        $person = new Object();
        $person->setObjectType('person');
        $person->setDisplayName('Joe');
        $persons = new Collection();
        $persons->add($person);
        $event = new Event();
        $event->setDisplayName('Meeting with Joe');
        $event->setStartTime(new DateTime('2012-12-12T12:00:00Z'));
        $event->setEndTime(new DateTime('2012-12-12T13:00:00Z'));
        $event->setValidFrom(new DateTime('2012-12-12T13:00:00Z'));
        $event->setValidAfter(new DateTime('2012-12-12T13:00:00Z'));
        $event->setValidUntil(new DateTime('2012-12-12T13:00:00Z'));
        $event->setValidBefore(new DateTime('2012-12-12T13:00:00Z'));
        $event->setAttendedBy($persons);
        $event->setAttending($persons);
        $event->setInvited($persons);
        $event->setMaybeAttending($persons);
        $event->setNotAttendedBy($persons);
        $event->setNotAttending($persons);
        $content = <<<JSON
{
  "attendedBy": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "attending": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "endTime": "2012-12-12T13:00:00Z",
  "invited": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "maybeAttending": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "notAttendedBy": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "notAttending": {"items": [{
        "objectType": "person",
        "displayName": "Joe"
      }]},
  "startTime": "2012-12-12T12:00:00Z",
  "validFrom": "2012-12-12T13:00:00Z",
  "validAfter": "2012-12-12T13:00:00Z",
  "validUntil": "2012-12-12T13:00:00Z",
  "validBefore": "2012-12-12T13:00:00Z",
  "objectType": "event",
  "displayName": "Meeting with Joe"
}
JSON;
        $this->assertRecordEqualsContent($event, $content);
        $this->assertEquals('Meeting with Joe', $event->getDisplayName());
        $this->assertEquals(new DateTime('2012-12-12T12:00:00Z'), $event->getStartTime());
        $this->assertEquals(new DateTime('2012-12-12T13:00:00Z'), $event->getEndTime());
        $this->assertEquals(new DateTime('2012-12-12T13:00:00Z'), $event->getValidFrom());
        $this->assertEquals(new DateTime('2012-12-12T13:00:00Z'), $event->getValidAfter());
        $this->assertEquals(new DateTime('2012-12-12T13:00:00Z'), $event->getValidUntil());
        $this->assertEquals(new DateTime('2012-12-12T13:00:00Z'), $event->getValidBefore());
        $this->assertEquals($persons, $event->getAttendedBy());
        $this->assertEquals($persons, $event->getAttending());
        $this->assertEquals($persons, $event->getInvited());
        $this->assertEquals($persons, $event->getMaybeAttending());
        $this->assertEquals($persons, $event->getNotAttendedBy());
        $this->assertEquals($persons, $event->getNotAttending());
    }
예제 #14
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle(Util::stripAndTruncateHtml($this->summary));
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, 'urn:uuid:' . $this->authorGlobalId);
             $entry->setContent($this->summary, 'html');
             if ($this->parentId > 0) {
                 $writer = $result->getWriter()->writer;
                 $parent = $this->_table->select(array('id', 'globalId', 'date'))->where('id', '=', $this->parentId)->getRow();
                 $writer->startElementNS('thr', 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
                 $writer->writeAttribute('ref', 'urn:uuid:' . $parent['globalId']);
                 $writer->endElement();
             }
             return $entry;
             break;
         case WriterInterface::JAS:
             $object = $this->getObject();
             if (empty($object)) {
                 $image = new ActivityStream\MediaLink();
                 $image->setUrl($this->authorThumbnailUrl);
                 $actor = new ActivityStream\Object();
                 $actor->setObjectType('person');
                 $actor->setDisplayName($this->authorName);
                 $actor->setUrl($this->authorProfileUrl);
                 $actor->setImage($image);
                 $object = new ActivityStream\Object();
                 $object->setObjectType('note');
                 $object->setId('urn:uuid:' . $this->globalId);
                 $object->setDisplayName(Util::stripAndTruncateHtml($this->summary));
                 $object->setPublished($this->getDate());
                 $object->setContent($this->summary);
                 $activity = new ActivityStream\Activity();
                 $activity->setActor($actor);
                 $activity->setVerb('post');
                 $activity->setObject($object);
                 return $activity;
             } else {
                 return $object;
             }
             break;
         default:
             return parent::export($result);
             break;
     }
 }