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); }
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); }