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('GNUSOCIAL', true);
10 define('STATUSNET', true); // compatibility
12 require_once INSTALLDIR . '/lib/common.php';
14 class UserFeedParseTests extends PHPUnit_Framework_TestCase
16 public function testFeed1()
19 $dom = DOMDocument::loadXML($_testfeed1);
20 $this->assertFalse(empty($dom));
22 $entries = $dom->getElementsByTagName('entry');
24 $entry1 = $entries->item(0);
25 $this->assertFalse(empty($entry1));
27 $feedEl = $dom->getElementsByTagName('feed')->item(0);
28 $this->assertFalse(empty($feedEl));
30 // Test actor (from activity:subject)
32 $act1 = new Activity($entry1, $feedEl);
33 $this->assertFalse(empty($act1));
34 $this->assertFalse(empty($act1->actor));
35 $this->assertEquals($act1->actor->type, ActivityObject::PERSON);
36 $this->assertEquals($act1->actor->title, 'Zach Copley');
37 $this->assertEquals($act1->actor->id, 'http://localhost/statusnet/user/1');
38 $this->assertEquals($act1->actor->link, 'http://localhost/statusnet/zach');
40 $avatars = $act1->actor->avatarLinks;
44 'http://localhost/statusnet/theme/default/default-avatar-profile.png'
49 'http://localhost/statusnet/theme/default/default-avatar-stream.png'
54 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
57 $this->assertEquals($act1->actor->displayName, 'Zach Copley');
59 $poco = $act1->actor->poco;
60 $this->assertEquals($poco->preferredUsername, 'zach');
61 $this->assertEquals($poco->address->formatted, 'El Cerrito, CA');
62 $this->assertEquals($poco->urls[0]->type, 'homepage');
63 $this->assertEquals($poco->urls[0]->value, 'http://zach.copley.name');
64 $this->assertEquals($poco->urls[0]->primary, 'true');
65 $this->assertEquals($poco->note, 'Zach Hack Attack');
70 $this->assertEquals($act1->objects[0]->type, 'http://activitystrea.ms/schema/1.0/note');
71 $this->assertEquals($act1->objects[0]->title, 'And now for something completely insane...');
73 $this->assertEquals($act1->objects[0]->content, 'And now for something completely insane...');
74 $this->assertEquals($act1->objects[0]->id, 'http://localhost/statusnet/notice/3');
80 $_testfeed1 = <<<TESTFEED1
81 <?xml version="1.0" encoding="UTF-8"?>
82 <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">
83 <id>http://localhost/statusnet/api/statuses/user_timeline/1.atom</id>
84 <title>zach timeline</title>
85 <subtitle>Updates from zach on Zach Dev!</subtitle>
86 <logo>http://localhost/statusnet/theme/default/default-avatar-profile.png</logo>
87 <updated>2010-03-04T01:41:14+00:00</updated>
90 <uri>http://localhost/statusnet/user/1</uri>
93 <link href="http://localhost/statusnet/zach" rel="alternate" type="text/html"/>
94 <link href="http://localhost/statusnet/main/sup#1" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
95 <link href="http://localhost/statusnet/main/push/hub" rel="hub"/>
96 <link href="http://localhost/statusnet/main/salmon/user/1" rel="http://salmon-protocol.org/ns/salmon-replies"/>
97 <link href="http://localhost/statusnet/main/salmon/user/1" rel="http://salmon-protocol.org/ns/salmon-mention"/>
98 <link href="http://localhost/statusnet/api/statuses/user_timeline/1.atom" rel="self" type="application/atom+xml"/>
100 <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
101 <id>http://localhost/statusnet/user/1</id>
102 <title>Zach Copley</title>
103 <link rel="alternate" type="text/html" href="http://localhost/statusnet/zach"/>
104 <link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://localhost/statusnet/theme/default/default-avatar-profile.png"/>
105 <link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://localhost/statusnet/theme/default/default-avatar-stream.png"/>
106 <link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://localhost/statusnet/theme/default/default-avatar-mini.png"/>
108 <poco:preferredUsername>zach</poco:preferredUsername>
109 <poco:displayName>Zach Copley</poco:displayName>
110 <poco:note>Zach Hack Attack</poco:note>
112 <poco:formatted>El Cerrito, CA</poco:formatted>
115 <poco:type>homepage</poco:type>
116 <poco:value>http://zach.copley.name</poco:value>
117 <poco:primary>true</poco:primary>
122 <title>And now for something completely insane...</title>
123 <link rel="alternate" type="text/html" href="http://localhost/statusnet/notice/3"/>
124 <id>http://localhost/statusnet/notice/3</id>
125 <published>2010-03-04T01:41:07+00:00</published>
126 <updated>2010-03-04T01:41:07+00:00</updated>
127 <link rel="ostatus:conversation" href="http://localhost/statusnet/conversation/3"/>
128 <content type="html">And now for something completely insane...</content>