3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
11 require_once INSTALLDIR . '/lib/common.php';
13 class UserFeedParseTests extends PHPUnit_Framework_TestCase
15 public function testFeed1()
18 $dom = DOMDocument::loadXML($_testfeed1);
19 $this->assertFalse(empty($dom));
21 $entries = $dom->getElementsByTagName('entry');
23 $entry1 = $entries->item(0);
24 $this->assertFalse(empty($entry1));
26 $feedEl = $dom->getElementsByTagName('feed')->item(0);
27 $this->assertFalse(empty($feedEl));
29 // Test actor (from activity:subject)
31 $act1 = new Activity($entry1, $feedEl);
32 $this->assertFalse(empty($act1));
33 $this->assertFalse(empty($act1->actor));
34 $this->assertEquals($act1->actor->type, ActivityObject::PERSON);
35 $this->assertEquals($act1->actor->title, 'Zach Copley');
36 $this->assertEquals($act1->actor->id, 'http://localhost/statusnet/user/1');
37 $this->assertEquals($act1->actor->link, 'http://localhost/statusnet/zach');
39 $avatars = $act1->actor->avatarLinks;
43 'http://localhost/statusnet/theme/default/default-avatar-profile.png'
48 'http://localhost/statusnet/theme/default/default-avatar-stream.png'
53 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
56 $this->assertEquals($act1->actor->displayName, 'Zach Copley');
58 $poco = $act1->actor->poco;
59 $this->assertEquals($poco->preferredUsername, 'zach');
60 $this->assertEquals($poco->address->formatted, 'El Cerrito, CA');
61 $this->assertEquals($poco->urls[0]->type, 'homepage');
62 $this->assertEquals($poco->urls[0]->value, 'http://zach.copley.name');
63 $this->assertEquals($poco->urls[0]->primary, 'true');
64 $this->assertEquals($poco->note, 'Zach Hack Attack');
69 $this->assertEquals($act1->objects[0]->type, 'http://activitystrea.ms/schema/1.0/note');
70 $this->assertEquals($act1->objects[0]->title, 'And now for something completely insane...');
72 $this->assertEquals($act1->objects[0]->content, 'And now for something completely insane...');
73 $this->assertEquals($act1->objects[0]->id, 'http://localhost/statusnet/notice/3');
79 $_testfeed1 = <<<TESTFEED1
80 <?xml version="1.0" encoding="UTF-8"?>
81 <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0">
82 <id>http://localhost/statusnet/api/statuses/user_timeline/1.atom</id>
83 <title>zach timeline</title>
84 <subtitle>Updates from zach on Zach Dev!</subtitle>
85 <logo>http://localhost/statusnet/theme/default/default-avatar-profile.png</logo>
86 <updated>2010-03-04T01:41:14+00:00</updated>
89 <uri>http://localhost/statusnet/user/1</uri>
92 <link href="http://localhost/statusnet/zach" rel="alternate" type="text/html"/>
93 <link href="http://localhost/statusnet/main/sup#1" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
94 <link href="http://localhost/statusnet/main/push/hub" rel="hub"/>
95 <link href="http://localhost/statusnet/main/salmon/user/1" rel="http://salmon-protocol.org/ns/salmon-replies"/>
96 <link href="http://localhost/statusnet/main/salmon/user/1" rel="http://salmon-protocol.org/ns/salmon-mention"/>
97 <link href="http://localhost/statusnet/api/statuses/user_timeline/1.atom" rel="self" type="application/atom+xml"/>
99 <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
100 <id>http://localhost/statusnet/user/1</id>
101 <title>Zach Copley</title>
102 <link rel="alternate" type="text/html" href="http://localhost/statusnet/zach"/>
103 <link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://localhost/statusnet/theme/default/default-avatar-profile.png"/>
104 <link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://localhost/statusnet/theme/default/default-avatar-stream.png"/>
105 <link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://localhost/statusnet/theme/default/default-avatar-mini.png"/>
107 <poco:preferredUsername>zach</poco:preferredUsername>
108 <poco:displayName>Zach Copley</poco:displayName>
109 <poco:note>Zach Hack Attack</poco:note>
111 <poco:formatted>El Cerrito, CA</poco:formatted>
114 <poco:type>homepage</poco:type>
115 <poco:value>http://zach.copley.name</poco:value>
116 <poco:primary>true</poco:primary>
121 <title>And now for something completely insane...</title>
122 <link rel="alternate" type="text/html" href="http://localhost/statusnet/notice/3"/>
123 <id>http://localhost/statusnet/notice/3</id>
124 <published>2010-03-04T01:41:07+00:00</published>
125 <updated>2010-03-04T01:41:07+00:00</updated>
126 <link rel="ostatus:conversation" href="http://localhost/statusnet/conversation/3"/>
127 <content type="html">And now for something completely insane...</content>