From dc09453a77f33c4dfdff306321ce93cf5fbd2d57 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Mon, 8 Feb 2010 11:06:03 -0800
Subject: First steps on converting FeedSub into the pub/sub basis for OStatus
communications: * renamed FeedSub plugin to OStatus * now setting avatar on
subscriptions * general fixes for subscription * integrated PuSH hub to
handle only user timelines on canonical ID url; sends updates directly * set
$config['feedsub']['nohub'] = true to test w/ foreign feeds that don't have
hubs (won't actually receive updates though) * a few bits of code
documentation * HMAC support for verified distributions (safest if sub setup
is on HTTPS)
And a couple core changes:
* minimizing HTML output for exceptions in API requests to aid in debugging
* fix for rel=self link in apitimelineuser when id given
This does not not yet include any of the individual subscription management (Salmon notifications for sub/unsub, etc) nor a nice UI for user subscriptions.
Needs some further cleanup to treat posts as status updates instead of link references.
---
plugins/OStatus/tests/FeedMungerTest.php | 147 +++++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
create mode 100644 plugins/OStatus/tests/FeedMungerTest.php
(limited to 'plugins/OStatus/tests/FeedMungerTest.php')
diff --git a/plugins/OStatus/tests/FeedMungerTest.php b/plugins/OStatus/tests/FeedMungerTest.php
new file mode 100644
index 000000000..0ce24c9fb
--- /dev/null
+++ b/plugins/OStatus/tests/FeedMungerTest.php
@@ -0,0 +1,147 @@
+profile();
+
+ foreach ($expected as $field => $val) {
+ $this->assertEquals($expected[$field], $profile->$field, "profile->$field");
+ }
+ }
+
+ static public function profileProvider()
+ {
+ return array(
+ array(self::samplefeed(),
+ array('nickname' => 'leŭksman', // @todo does this need to be asciified?
+ 'fullname' => 'leŭksman',
+ 'bio' => 'reticula, electronica, & oddities',
+ 'homepage' => 'http://leuksman.com/log')));
+ }
+
+ /**
+ * @dataProvider noticeProvider
+ *
+ */
+ public function testNotices($xml, $entryIndex, $expected)
+ {
+ $feed = new XML_Feed_Parser($xml, false, false, true);
+ $entry = $feed->getEntryByOffset($entryIndex);
+
+ $munger = new FeedMunger($feed);
+ $notice = $munger->noticeFromEntry($entry);
+
+ $this->assertTrue(mb_strlen($notice) <= Notice::maxContent());
+ $this->assertEquals($expected, $notice);
+ }
+
+ static public function noticeProvider()
+ {
+ return array(
+ array('A fairly short titlehttp://example.com/short/link', 0,
+ 'New post: "A fairly short title" http://example.com/short/link'),
+ // Requires URL shortening ...
+ array('A fairly short titlehttp://example.com/but/a/very/long/link/indeed/this/is/far/too/long/for/mere/humans/to/comprehend/oh/my/gosh', 0,
+ 'New post: "A fairly short title" http://ur1.ca/g2o1'),
+ array('A fairly long title in this case, which will have to get cut down at some point alongside its very long link. Really who even makes titles this long? It\'s just ridiculous imo...http://example.com/but/a/very/long/link/indeed/this/is/far/too/long/for/mere/humans/to/comprehend/oh/my/gosh', 0,
+ 'New post: "A fairly long title in this case, which will have to get cut down at some point alongside its very long li…" http://ur1.ca/g2o1'),
+ // Some real sample feeds
+ array(self::samplefeed(), 0,
+ 'New post: "Compiling PHP on Snow Leopard" http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/'),
+ array(self::samplefeedBlogspot(), 0,
+ 'New post: "I love posting" http://briontest.blogspot.com/2009/11/i-love-posting.html'),
+ array(self::samplefeedBlogspot(), 1,
+ 'New post: "Hey dude" http://briontest.blogspot.com/2009/11/hey-dude.html'),
+ );
+ }
+
+ static protected function samplefeed()
+ {
+ $xml = '<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n";
+ $samplefeed = $xml . <<
+
+
+ leŭksman
+
+ http://leuksman.com/log
+ reticula, electronica, & oddities
+
+ Thu, 12 Nov 2009 17:44:42 +0000
+ http://wordpress.org/?v=2.8.6
+ en
+ hourly
+ 1
+
+
+ Compiling PHP on Snow Leopard
+ http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/
+ http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/#comments
+ Thu, 12 Nov 2009 17:44:42 +0000
+ brion
+
+
+
+
+ http://leuksman.com/log/?p=649
+
+ If you’ve been having trouble compiling your own PHP installations on Mac OS X 10.6, here’s the secret to making it not suck! After running the configure script, edit the generated Makefile and make these fixes:
+
+
Find the EXTRA_LIBS definition and add -lresolv to the end
+
Find the EXE_EXT definition and remove .dSYM
+
+
Standard make and make install should work from here…
+
For reference, here’s the whole configure line I currently use; MySQL is installed from the downloadable installer; other deps from MacPorts: