Пример #1
0
    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);
    }