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);
10 define('LACONICA', true);
12 require_once INSTALLDIR . '/lib/common.php';
13 require_once INSTALLDIR . '/plugins/FeedSub/feedsub.php';
15 class FeedDiscoveryTest extends PHPUnit_Framework_TestCase
18 * @dataProvider provider
21 public function testProduction($url, $html, $expected)
23 $sub = new FeedDiscovery();
24 $url = $sub->discoverFromHTML($url, $html);
25 $this->assertEquals($expected, $url);
28 static public function provider()
30 $sampleHeader = <<<END
31 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32 <html xmlns="http://www.w3.org/1999/xhtml">
34 <head profile="http://gmpg.org/xfn/11">
35 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
37 <title>leŭksman </title>
39 <meta name="generator" content="WordPress 2.8.6" /> <!-- leave this for stats -->
41 <link rel="stylesheet" href="http://leuksman.com/log/wp-content/themes/leuksman/style.css" type="text/css" media="screen" />
42 <link rel="alternate" type="application/rss+xml" title="leŭksman RSS Feed" href="http://leuksman.com/log/feed/" />
43 <link rel="pingback" href="http://leuksman.com/log/xmlrpc.php" />
45 <meta name="viewport" content="width = 640" />
47 <xmeta name="viewport" content="initial-scale=2.3, user-scalable=no" />
49 <style type="text/css" media="screen">
51 #page { background: url("http://leuksman.com/log/wp-content/themes/leuksman/images/kubrickbg.jpg") repeat-y top; border: none; }
55 <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://leuksman.com/log/xmlrpc.php?rsd" />
56 <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://leuksman.com/log/wp-includes/wlwmanifest.xml" />
57 <link rel='index' title='leŭksman' href='http://leuksman.com/log' />
58 <meta name="generator" content="WordPress 2.8.6" />
65 array('http://example.com/',
66 '<html><link rel="alternate" href="http://example.com/feed/rss" type="application/rss+xml">',
67 'http://example.com/feed/rss'),
68 array('http://example.com/atom',
69 '<html><link rel="alternate" href="http://example.com/feed/atom" type="application/atom+xml">',
70 'http://example.com/feed/atom'),
71 array('http://example.com/empty',
72 '<html><link rel="alternate" href="http://example.com/index.pdf" type="application/pdf">',
74 array('http://example.com/tagsoup',
75 '<body><pre><LINK rel=alternate hRef=http://example.com/feed/rss type=application/rss+xml><fnork',
76 'http://example.com/feed/rss'),
77 // 'rel' attribute must be lowercase, alone per http://www.rssboard.org/rss-autodiscovery
78 array('http://example.com/tagsoup2',
79 '<body><pre><LINK rel=" feeders alternate 467" hRef=http://example.com/feed/rss type=application/rss+xml><fnork',
81 array('http://example.com/tagsoup3',
82 '<body><pre><LINK rel=ALTERNATE hRef=http://example.com/feed/rss type=application/rss+xml><fnork',
84 array('http://example.com/relative/link1',
85 '<html><link rel="alternate" href="/feed/rss" type="application/rss+xml">',
86 'http://example.com/feed/rss'),
87 array('http://example.com/relative/link2',
88 '<html><link rel="alternate" href="../feed/rss" type="application/rss+xml">',
89 'http://example.com/feed/rss'),
90 array('http://example.com/relative/link3',
91 '<html><link rel="alternate" href="http:/feed/rss" type="application/rss+xml">',
92 'http://example.com/feed/rss'),
93 array('http://example.com/base/link1',
94 '<html><link rel="alternate" href="/feed/rss" type="application/rss+xml"><base href="http://target.example.com/">',
95 'http://target.example.com/feed/rss'),
96 array('http://example.com/base/link2',
97 '<html><link rel="alternate" href="feed/rss" type="application/rss+xml"><base href="http://target.example.com/">',
98 'http://target.example.com/feed/rss'),
99 array('http://example.com/base/link3',
100 '<html><link rel="alternate" href="http:/feed/rss" type="application/rss+xml"><base href="http://target.example.com/">',
101 'http://target.example.com/feed/rss'),
102 // Trick question! There's a <base> but no href on it
103 array('http://example.com/relative/fauxbase',
104 '<html><link rel="alternate" href="../feed/rss" type="application/rss+xml"><base target="top">',
105 'http://example.com/feed/rss'),
106 // Actual WordPress blog header example
107 array('http://leuksman.com/log/',
109 'http://leuksman.com/log/feed/'));