Exemplo n.º 1
0
    public function testActivity()
    {
        $image = new Object();
        $image->setUrl('http://example.org/martin/image.jpg');
        $image->setMediaType('image/jpeg');
        $image->setWidth(250);
        $image->setHeight(250);
        $actor = new Object();
        $actor->setObjectType('person');
        $actor->setId('urn:example:person:martin');
        $actor->setDisplayName('Martin Smith');
        $actor->setUrl('http://example.org/martin');
        $actor->setImage($image);
        $object = new Object();
        $object->setObjectType('article');
        $object->setId('urn:example:blog:abc123/xyz');
        $object->setUrl('http://example.org/blog/2011/02/entry');
        $object->setDisplayName('Why I love Activity Streams');
        $target = new Object();
        $target->setObjectType('blog');
        $target->setId('urn:example:blog:abc123');
        $target->setDisplayName('Martin\'s Blog');
        $target->setUrl('http://example.org/blog/');
        $activity = new Activity();
        $activity->setVerb('post');
        $activity->setPublished(new DateTime('2011-02-10T15:04:55Z'));
        $activity->setLanguage('en');
        $activity->setActor($actor);
        $activity->setObject($object);
        $activity->setTarget($target);
        $activity->setResult($image);
        $activity->setPriority(0.5);
        $activity->setTo($actor);
        $activity->setCc($actor);
        $activity->setBto($actor);
        $activity->setBcc($actor);
        $content = <<<JSON
{
  "verb": "post",
  "actor": {
    "id": "urn:example:person:martin",
    "objectType": "person",
    "displayName": "Martin Smith",
    "url": "http://example.org/martin",
    "image": {
      "mediaType": "image/jpeg",
      "url": "http://example.org/martin/image.jpg",
      "height": 250,
      "width": 250
    }
  },
  "object": {
    "id": "urn:example:blog:abc123/xyz",
    "objectType": "article",
    "displayName": "Why I love Activity Streams",
    "url": "http://example.org/blog/2011/02/entry"
  },
  "target": {
    "id": "urn:example:blog:abc123",
    "objectType": "blog",
    "displayName": "Martin's Blog",
    "url": "http://example.org/blog/"
  },
  "result": {
    "mediaType": "image/jpeg",
    "url": "http://example.org/martin/image.jpg",
    "height": 250,
    "width": 250
  },
  "priority": 0.5,
  "to": {
    "id": "urn:example:person:martin",
    "objectType": "person",
    "displayName": "Martin Smith",
    "url": "http://example.org/martin",
    "image": {
      "mediaType": "image/jpeg",
      "url": "http://example.org/martin/image.jpg",
      "height": 250,
      "width": 250
    }
  },
  "cc": {
    "id": "urn:example:person:martin",
    "objectType": "person",
    "displayName": "Martin Smith",
    "url": "http://example.org/martin",
    "image": {
      "mediaType": "image/jpeg",
      "url": "http://example.org/martin/image.jpg",
      "height": 250,
      "width": 250
    }
  },
  "bto": {
    "id": "urn:example:person:martin",
    "objectType": "person",
    "displayName": "Martin Smith",
    "url": "http://example.org/martin",
    "image": {
      "mediaType": "image/jpeg",
      "url": "http://example.org/martin/image.jpg",
      "height": 250,
      "width": 250
    }
  },
  "bcc": {
    "id": "urn:example:person:martin",
    "objectType": "person",
    "displayName": "Martin Smith",
    "url": "http://example.org/martin",
    "image": {
      "mediaType": "image/jpeg",
      "url": "http://example.org/martin/image.jpg",
      "height": 250,
      "width": 250
    }
  },
  "language": "en",
  "published": "2011-02-10T15:04:55Z"
}
JSON;
        $this->assertRecordEqualsContent($activity, $content);
        $this->assertEquals('post', $activity->getVerb());
        $this->assertEquals(new DateTime('2011-02-10T15:04:55Z'), $activity->getPublished());
        $this->assertEquals('en', $activity->getLanguage());
        $this->assertEquals($actor, $activity->getActor());
        $this->assertEquals($object, $activity->getObject());
        $this->assertEquals($target, $activity->getTarget());
        $this->assertEquals($image, $activity->getResult());
        $this->assertEquals(0.5, $activity->getPriority());
        $this->assertEquals($actor, $activity->getTo());
        $this->assertEquals($actor, $activity->getCc());
        $this->assertEquals($actor, $activity->getBto());
        $this->assertEquals($actor, $activity->getBcc());
    }