You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

536 lines
25 KiB

  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpFoundation\Response;
  4. class FeedTest extends PHPUnit\Framework\TestCase
  5. {
  6. private $http;
  7. public function setUp(): void
  8. {
  9. $this->client = new Parse();
  10. $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/');
  11. $this->client->mc = null;
  12. }
  13. private function parse($params)
  14. {
  15. $request = new Request($params);
  16. $response = new Response();
  17. return $this->client->parse($request, $response);
  18. }
  19. public function testListOfHEntrys()
  20. {
  21. $url = 'http://feed.example.com/list-of-hentrys';
  22. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  23. $body = $response->getContent();
  24. $this->assertEquals(200, $response->getStatusCode());
  25. $result = json_decode($body);
  26. $this->assertEquals('mf2+html', $result->{'source-format'});
  27. $data = $result->data;
  28. $this->assertEquals('feed', $data->type);
  29. $this->assertEquals(4, count($data->items));
  30. $this->assertEquals('One', $data->items[0]->name);
  31. $this->assertEquals('article', $data->items[0]->{'post-type'});
  32. $this->assertEquals('Two', $data->items[1]->name);
  33. $this->assertEquals('article', $data->items[1]->{'post-type'});
  34. $this->assertEquals('Three', $data->items[2]->name);
  35. $this->assertEquals('Four', $data->items[3]->name);
  36. }
  37. public function testListOfHEntrysWithHCard()
  38. {
  39. $url = 'http://feed.example.com/list-of-hentrys-with-h-card';
  40. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  41. $body = $response->getContent();
  42. $this->assertEquals(200, $response->getStatusCode());
  43. $result = json_decode($body);
  44. $this->assertEquals('mf2+html', $result->{'source-format'});
  45. $data = $result->data;
  46. $this->assertEquals('feed', $data->type);
  47. $this->assertEquals(4, count($data->items));
  48. $this->assertEquals('One', $data->items[0]->name);
  49. $this->assertEquals('article', $data->items[0]->{'post-type'});
  50. $this->assertEquals('Two', $data->items[1]->name);
  51. $this->assertEquals('Three', $data->items[2]->name);
  52. $this->assertEquals('Four', $data->items[3]->name);
  53. // Check that the author h-card was matched up with each h-entry
  54. $this->assertEquals('Author Name', $data->items[0]->author->name);
  55. $this->assertEquals('Author Name', $data->items[1]->author->name);
  56. $this->assertEquals('Author Name', $data->items[2]->author->name);
  57. $this->assertEquals('Author Name', $data->items[3]->author->name);
  58. }
  59. public function testListOfHEntrysWithHCardNoExpect()
  60. {
  61. $url = 'http://feed.example.com/list-of-hentrys-with-h-card';
  62. $response = $this->parse(['url' => $url]);
  63. $body = $response->getContent();
  64. $this->assertEquals(200, $response->getStatusCode());
  65. $result = json_decode($body);
  66. $this->assertEquals('mf2+html', $result->{'source-format'});
  67. $data = $result->data;
  68. $this->assertEquals('feed', $data->type);
  69. $this->assertEquals(4, count($data->items));
  70. $this->assertEquals('One', $data->items[0]->name);
  71. $this->assertEquals('article', $data->items[0]->{'post-type'});
  72. $this->assertEquals('Two', $data->items[1]->name);
  73. $this->assertEquals('Three', $data->items[2]->name);
  74. $this->assertEquals('Four', $data->items[3]->name);
  75. // Check that the author h-card was matched up with each h-entry
  76. $this->assertEquals('Author Name', $data->items[0]->author->name);
  77. $this->assertEquals('Author Name', $data->items[1]->author->name);
  78. $this->assertEquals('Author Name', $data->items[2]->author->name);
  79. $this->assertEquals('Author Name', $data->items[3]->author->name);
  80. }
  81. public function testShortListOfHEntrysWithHCardNoExpect()
  82. {
  83. $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card';
  84. $response = $this->parse(['url' => $url]);
  85. $body = $response->getContent();
  86. $this->assertEquals(200, $response->getStatusCode());
  87. $result = json_decode($body);
  88. $this->assertEquals('mf2+html', $result->{'source-format'});
  89. $data = $result->data;
  90. // In this case, this looks like a page permalink
  91. $this->assertEquals('entry', $data->type);
  92. // This test should find the h-entry rather than the h-card, because the h-card does not contain the page URL
  93. $this->assertEquals('http://feed.example.com/1', $data->url);
  94. $this->assertEquals('Author', $data->author->name);
  95. }
  96. public function testShortListOfHEntrysWithHCard()
  97. {
  98. $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card';
  99. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  100. $body = $response->getContent();
  101. $this->assertEquals(200, $response->getStatusCode());
  102. $result = json_decode($body);
  103. $this->assertEquals('mf2+html', $result->{'source-format'});
  104. $data = $result->data;
  105. $this->assertEquals('feed', $data->type);
  106. // This test should find the h-entry rather than the h-card, because expect=feed
  107. $this->assertEquals('entry', $data->items[0]->type);
  108. $this->assertEquals('http://feed.example.com/1', $data->items[0]->url);
  109. $this->assertEquals('Author', $data->items[0]->author->name);
  110. }
  111. public function testTopLevelHFeed()
  112. {
  113. $url = 'http://feed.example.com/top-level-h-feed';
  114. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  115. $body = $response->getContent();
  116. $this->assertEquals(200, $response->getStatusCode());
  117. $result = json_decode($body);
  118. $this->assertEquals('mf2+html', $result->{'source-format'});
  119. $data = $result->data;
  120. $this->assertEquals('feed', $data->type);
  121. $this->assertEquals(4, count($data->items));
  122. $this->assertEquals('One', $data->items[0]->name);
  123. $this->assertEquals('Two', $data->items[1]->name);
  124. $this->assertEquals('Three', $data->items[2]->name);
  125. $this->assertEquals('Four', $data->items[3]->name);
  126. }
  127. public function testTopLevelHFeedWithChildAuthor()
  128. {
  129. $url = 'http://feed.example.com/h-feed-with-child-author';
  130. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  131. $body = $response->getContent();
  132. $this->assertEquals(200, $response->getStatusCode());
  133. $result = json_decode($body);
  134. $this->assertEquals('mf2+html', $result->{'source-format'});
  135. $data = $result->data;
  136. $this->assertEquals('feed', $data->type);
  137. $this->assertEquals(4, count($data->items));
  138. $this->assertEquals('One', $data->items[0]->name);
  139. $this->assertEquals('Two', $data->items[1]->name);
  140. $this->assertEquals('Three', $data->items[2]->name);
  141. $this->assertEquals('Four', $data->items[3]->name);
  142. $this->assertEquals('Author Name', $data->items[0]->author->name);
  143. $this->assertEquals('Author Name', $data->items[1]->author->name);
  144. $this->assertEquals('Author Name', $data->items[2]->author->name);
  145. $this->assertEquals('Author Name', $data->items[3]->author->name);
  146. }
  147. public function testHCardWithChildHEntrys()
  148. {
  149. $url = 'http://feed.example.com/h-card-with-child-h-entrys';
  150. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  151. $body = $response->getContent();
  152. $this->assertEquals(200, $response->getStatusCode());
  153. $result = json_decode($body);
  154. $this->assertEquals('mf2+html', $result->{'source-format'});
  155. $data = $result->data;
  156. $this->assertEquals('feed', $data->type);
  157. $this->assertEquals(4, count($data->items));
  158. $this->assertEquals('One', $data->items[0]->name);
  159. $this->assertEquals('Two', $data->items[1]->name);
  160. $this->assertEquals('Three', $data->items[2]->name);
  161. $this->assertEquals('Four', $data->items[3]->name);
  162. }
  163. public function testHCardWithSiblingHEntrys()
  164. {
  165. $url = 'http://feed.example.com/h-card-with-sibling-h-entrys';
  166. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  167. $body = $response->getContent();
  168. $this->assertEquals(200, $response->getStatusCode());
  169. $result = json_decode($body);
  170. $this->assertEquals('mf2+html', $result->{'source-format'});
  171. $data = $result->data;
  172. $this->assertEquals('feed', $data->type);
  173. $this->assertEquals(4, count($data->items));
  174. $this->assertEquals('One', $data->items[0]->name);
  175. $this->assertEquals('Two', $data->items[1]->name);
  176. $this->assertEquals('Three', $data->items[2]->name);
  177. $this->assertEquals('Four', $data->items[3]->name);
  178. // Check that the author h-card was matched up with each h-entry
  179. $this->assertEquals('Author Name', $data->items[0]->author->name);
  180. $this->assertEquals('Author Name', $data->items[1]->author->name);
  181. $this->assertEquals('Author Name', $data->items[2]->author->name);
  182. $this->assertEquals('Author Name', $data->items[3]->author->name);
  183. }
  184. public function testHCardWithChildHFeed()
  185. {
  186. $url = 'http://feed.example.com/h-card-with-child-h-feed';
  187. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  188. $body = $response->getContent();
  189. $this->assertEquals(200, $response->getStatusCode());
  190. $result = json_decode($body);
  191. $this->assertEquals('mf2+html', $result->{'source-format'});
  192. $data = $result->data;
  193. $this->assertEquals('feed', $data->type);
  194. $this->assertEquals(4, count($data->items));
  195. $this->assertEquals('One', $data->items[0]->name);
  196. $this->assertEquals('Two', $data->items[1]->name);
  197. $this->assertEquals('Three', $data->items[2]->name);
  198. $this->assertEquals('Four', $data->items[3]->name);
  199. // Check that the author h-card was matched up with each h-entry
  200. $this->assertEquals('Author Name', $data->items[0]->author->name);
  201. $this->assertEquals('Author Name', $data->items[1]->author->name);
  202. $this->assertEquals('Author Name', $data->items[2]->author->name);
  203. $this->assertEquals('Author Name', $data->items[3]->author->name);
  204. }
  205. public function testHCardWithChildHFeedNoExpect()
  206. {
  207. $url = 'http://feed.example.com/h-card-with-child-h-feed';
  208. $response = $this->parse(['url' => $url]);
  209. $body = $response->getContent();
  210. $this->assertEquals(200, $response->getStatusCode());
  211. $result = json_decode($body);
  212. $this->assertEquals('mf2+html', $result->{'source-format'});
  213. $data = $result->data;
  214. $this->assertEquals('card', $data->type);
  215. $this->assertEquals('Author Name', $data->name);
  216. }
  217. public function testJSONFeed()
  218. {
  219. $url = 'http://feed.example.com/jsonfeed';
  220. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  221. $body = $response->getContent();
  222. $this->assertEquals(200, $response->getStatusCode());
  223. $result = json_decode($body);
  224. $this->assertEquals('feed+json', $result->{'source-format'});
  225. $data = $result->data;
  226. $this->assertEquals(11, count($data->items));
  227. for($i=0; $i<8; $i++) {
  228. $this->assertEquals('entry', $data->items[$i]->type);
  229. $this->assertEquals('manton', $data->items[$i]->author->name);
  230. $this->assertEquals('http://www.manton.org', $data->items[$i]->author->url);
  231. $this->assertNotEmpty($data->items[$i]->url);
  232. $this->assertNotEmpty($data->items[$i]->uid);
  233. $this->assertNotEmpty($data->items[$i]->published);
  234. $this->assertNotEmpty($data->items[$i]->content->html);
  235. $this->assertNotEmpty($data->items[$i]->content->text);
  236. }
  237. $this->assertEquals('note', $data->items[0]->{'post-type'});
  238. $this->assertEquals('article', $data->items[4]->{'post-type'});
  239. $this->assertEquals('<p>Coming up on a year since I wrote about how <a href="http://www.manton.org/2016/11/todays-social-networks-are-broken.html">today’s social networks are broken</a>. Still what I believe.</p>', $data->items[7]->content->html);
  240. $this->assertEquals('Coming up on a year since I wrote about how today’s social networks are broken. Still what I believe.', $data->items[7]->content->text);
  241. $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->url);
  242. $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->uid);
  243. $this->assertEquals('2017-11-07T21:00:42+00:00', $data->items[7]->published);
  244. $this->assertEquals('feed', $data->type);
  245. }
  246. public function testJSONFeedFallbackAuthor()
  247. {
  248. $url = 'http://feed.example.com/jsonfeed-author';
  249. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  250. $body = $response->getContent();
  251. $this->assertEquals(200, $response->getStatusCode());
  252. $result = json_decode($body);
  253. $this->assertEquals('feed+json', $result->{'source-format'});
  254. $data = $result->data;
  255. $this->assertEquals(11, count($data->items));
  256. for($i=0; $i<8; $i++) {
  257. $this->assertEquals('entry', $data->items[$i]->type);
  258. $this->assertEquals('Manton Reece', $data->items[$i]->author->name);
  259. $this->assertEquals('https://www.manton.org/', $data->items[$i]->author->url);
  260. $this->assertEquals('https://micro.blog/manton/avatar.jpg', $data->items[$i]->author->photo);
  261. }
  262. }
  263. public function testJSONFeedRelativeImages()
  264. {
  265. $url = 'http://feed.example.com/jsonfeed';
  266. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  267. $body = $response->getContent();
  268. $this->assertEquals(200, $response->getStatusCode());
  269. $result = json_decode($body);
  270. $this->assertEquals('feed+json', $result->{'source-format'});
  271. $data = $result->data;
  272. // Relative image on an item that has a url
  273. $this->assertEquals('http://www.manton.org/2017/11/image.jpg', $data->items[9]->photo[0]);
  274. // Relative image on an item that has no URL, fall back to feed URL
  275. $this->assertEquals('http://feed.example.com/image.jpg', $data->items[10]->photo[0]);
  276. // Relative image inside the content html
  277. $this->assertStringContainsString('http://www.manton.org/2017/11/img.jpg', $data->items[9]->content->html);
  278. }
  279. public function testAtomFeed()
  280. {
  281. $url = 'http://feed.example.com/atom';
  282. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  283. $body = $response->getContent();
  284. $this->assertEquals(200, $response->getStatusCode());
  285. $result = json_decode($body);
  286. $this->assertEquals('xml', $result->{'source-format'});
  287. $data = $result->data;
  288. $this->assertEquals(8, count($data->items));
  289. for($i=0; $i<8; $i++) {
  290. $this->assertEquals('entry', $data->items[$i]->type);
  291. $this->assertEquals('note', $data->items[$i]->{'post-type'});
  292. $this->assertEquals('Tantek', $data->items[$i]->author->name);
  293. $this->assertEquals('http://tantek.com/', $data->items[$i]->author->url);
  294. $this->assertNotEmpty($data->items[$i]->url);
  295. $this->assertNotEmpty($data->items[$i]->published);
  296. $this->assertNotEmpty($data->items[$i]->content->html);
  297. $this->assertNotEmpty($data->items[$i]->content->text);
  298. }
  299. $this->assertEquals('2017-11-08T23:53:00-08:00', $data->items[0]->published);
  300. $this->assertEquals('http://tantek.com/2017/312/t3/tam-trail-run-first-trail-half', $data->items[0]->url);
  301. $this->assertEquals('went to MORE Pancakes! this morning @RunJanji pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->text);
  302. $this->assertEquals('went to MORE Pancakes! this morning <a href="https://twitter.com/RunJanji">@RunJanji</a> pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->html);
  303. $this->assertEquals('feed', $data->type);
  304. }
  305. public function testRSSFeed()
  306. {
  307. $url = 'http://feed.example.com/rss';
  308. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  309. $body = $response->getContent();
  310. $this->assertEquals(200, $response->getStatusCode());
  311. $result = json_decode($body);
  312. $this->assertEquals('xml', $result->{'source-format'});
  313. $data = $result->data;
  314. $this->assertEquals(10, count($data->items));
  315. for($i=0; $i<10; $i++) {
  316. $this->assertEquals('entry', $data->items[$i]->type);
  317. $this->assertEquals(($i == 4 ? 'article' : 'note'), $data->items[$i]->{'post-type'});
  318. $this->assertEquals('Ryan Barrett', $data->items[$i]->author->name);
  319. $this->assertEquals('https://snarfed.org/', $data->items[$i]->author->url);
  320. $this->assertNotEmpty($data->items[$i]->url);
  321. $this->assertNotEmpty($data->items[$i]->published);
  322. $this->assertNotEmpty($data->items[$i]->content->html);
  323. if($i > 1) {
  324. $this->assertNotEmpty($data->items[$i]->content->text);
  325. }
  326. }
  327. $this->assertEquals('2017-09-12T20:09:12+00:00', $data->items[9]->published);
  328. $this->assertEquals('https://snarfed.org/2017-09-12_25492', $data->items[9]->url);
  329. $this->assertEquals(
  330. '<p>new business cards <img src="https://s.w.org/images/core/emoji/2.3/72x72/1f602.png" alt="😂" /></p>
  331. <p><img src="https://i0.wp.com/snarfed.org/w/wp-content/uploads/2017/09/IMG_20170912_131414_767.jpg?w=696&amp;ssl=1" alt="IMG_20170912_131414_767.jpg?w=696&amp;ssl=1" /></p>', $data->items[9]->content->html
  332. );
  333. $this->assertEquals('new business cards', $data->items[9]->content->text);
  334. $this->assertEquals('feed', $data->type);
  335. }
  336. public function testPodcastFeed()
  337. {
  338. $url = 'http://feed.example.com/podcast-rss';
  339. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  340. $body = $response->getContent();
  341. $this->assertEquals(200, $response->getStatusCode());
  342. $result = json_decode($body);
  343. $this->assertEquals('xml', $result->{'source-format'});
  344. $data = $result->data;
  345. $this->assertEquals(12, count($data->items));
  346. for($i=0; $i<12; $i++) {
  347. $this->assertEquals('entry', $data->items[$i]->type);
  348. $this->assertEquals('audio', $data->items[$i]->{'post-type'});
  349. $this->assertEquals('Aaron Parecki', $data->items[$i]->author->name);
  350. $this->assertEquals('https://percolator.today/', $data->items[$i]->author->url);
  351. $this->assertNotEmpty($data->items[$i]->url);
  352. $this->assertNotEmpty($data->items[$i]->published);
  353. $this->assertNotEmpty($data->items[$i]->name);
  354. $this->assertNotEmpty($data->items[$i]->content->html);
  355. $this->assertNotEmpty($data->items[$i]->content->text);
  356. $this->assertNotEmpty($data->items[$i]->audio);
  357. }
  358. $this->assertEquals('Episode 1: Welcome', $data->items[11]->name);
  359. $this->assertEquals('https://percolator.today/episode/1', $data->items[11]->url);
  360. $this->assertEquals('2017-09-20T07:00:00+00:00', $data->items[11]->published);
  361. $this->assertEquals('https://percolator.today/redirect.php?url=https%3A%2F%2Fpercolator.today%2Fmedia%2FPercolator_Episode_1.mp3', $data->items[11]->audio[0]);
  362. $this->assertStringContainsString('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->text);
  363. $this->assertStringContainsString('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->html);
  364. $this->assertStringContainsString('<li><a href="https://indieweb.org/multi-photo_vs_collection">multi-photo vs collection</a></li>', $data->items[11]->content->html);
  365. $this->assertEquals('feed', $data->type);
  366. }
  367. public function testInstagramAtomFeed()
  368. {
  369. $url = 'http://feed.example.com/instagram-atom';
  370. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  371. $body = $response->getContent();
  372. $this->assertEquals(200, $response->getStatusCode());
  373. $result = json_decode($body);
  374. $this->assertEquals('xml', $result->{'source-format'});
  375. $data = $result->data;
  376. $this->assertEquals(12, count($data->items));
  377. $this->assertEquals('Marshall Kirkpatrick', $data->items[11]->author->name);
  378. $this->assertEquals('https://www.instagram.com/marshallk/', $data->items[11]->author->url);
  379. $this->assertEquals('https://www.instagram.com/p/BcFjw9SHYql/', $data->items[11]->url);
  380. $this->assertEquals('2017-11-29T17:04:00+00:00', $data->items[11]->published);
  381. // Should remove the "name" since it's a prefix of the content
  382. $this->assertObjectNotHasAttribute('name', $data->items[11]);
  383. $this->assertEquals('Sometimes my job requires me to listen to 55 minutes of an hour long phone call while I go for a long walk on a sunny morning and wait for my turn to give an update. Pretty nice!', $data->items[11]->content->text);
  384. }
  385. public function testAscraeus()
  386. {
  387. $url = 'http://source.example.com/ascraeus';
  388. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  389. $body = $response->getContent();
  390. $this->assertEquals(200, $response->getStatusCode());
  391. $data = json_decode($body)->data;
  392. $this->assertEquals('feed', $data->type);
  393. $this->assertEquals(20, count($data->items));
  394. }
  395. public function testAdactioLinks()
  396. {
  397. $url = 'http://feed.example.com/adactio-links';
  398. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  399. $body = $response->getContent();
  400. $this->assertEquals(200, $response->getStatusCode());
  401. $data = json_decode($body)->data;
  402. $this->assertEquals('feed', $data->type);
  403. // 20 h-entrys followed by one h-card, which should have been removed and used as the author instead
  404. $this->assertEquals(20, count($data->items));
  405. $this->assertEquals('http://feed.example.com/links/14501', $data->items[0]->url);
  406. $this->assertEquals('http://feed.example.com/links/14445', $data->items[19]->url);
  407. $item = $data->items[0];
  408. $this->assertEquals('Jeremy Keith', $item->author->name);
  409. $this->assertEquals('https://adactio.com/', $item->author->url);
  410. }
  411. public function testWaterpigsFeed()
  412. {
  413. $url = 'http://feed.example.com/waterpigs';
  414. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  415. $body = $response->getContent();
  416. $this->assertEquals(200, $response->getStatusCode());
  417. $data = json_decode($body)->data;
  418. $this->assertEquals('feed', $data->type);
  419. $this->assertEquals(21, count($data->items));
  420. $item = $data->items[16];
  421. $this->assertEquals('Barnaby Walters', $item->author->name);
  422. $this->assertEquals('https://waterpigs.co.uk', $item->author->url);
  423. }
  424. public function testRSSWithNoXMLTag()
  425. {
  426. $url = 'http://feed.example.com/rss-no-xml-tag';
  427. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  428. $body = $response->getContent();
  429. $this->assertEquals(200, $response->getStatusCode());
  430. $data = json_decode($body)->data;
  431. $this->assertEquals('feed', $data->type);
  432. }
  433. public function testAuthorFeedOnHomePage()
  434. {
  435. $url = 'http://feed.example.com/h-feed-author-is-feed';
  436. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  437. $body = $response->getContent();
  438. $this->assertEquals(200, $response->getStatusCode());
  439. $parsed = json_decode($body, true);
  440. $data = $parsed['data'];
  441. $this->assertEquals('feed', $data['type']);
  442. $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][0]['author']['url']);
  443. $this->assertEquals('Author', $data['items'][0]['author']['name']);
  444. $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][1]['author']['url']);
  445. $this->assertEquals('Author', $data['items'][1]['author']['name']);
  446. }
  447. public function testAuthorFeedOnHomePageInvalid()
  448. {
  449. $url = 'http://feed.example.com/h-feed-author-is-bad-feed';
  450. $response = $this->parse(['url' => $url, 'expect' => 'feed']);
  451. $body = $response->getContent();
  452. $this->assertEquals(200, $response->getStatusCode());
  453. $parsed = json_decode($body, true);
  454. $data = $parsed['data'];
  455. $this->assertEquals('feed', $data['type']);
  456. $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][0]['author']['url']);
  457. $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][1]['author']['url']);
  458. }
  459. }