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.

85 lines
2.5 KiB

  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpFoundation\Response;
  4. class FeedTest extends PHPUnit_Framework_TestCase {
  5. private $http;
  6. public function setUp() {
  7. $this->client = new Parse();
  8. $this->client->http = new p3k\HTTPTest(dirname(__FILE__).'/data/');
  9. }
  10. private function parse($params) {
  11. $request = new Request($params);
  12. $response = new Response();
  13. return $this->client->parse($request, $response);
  14. }
  15. public function testListOfHEntrys() {
  16. $url = 'http://feed.example.com/list-of-hentrys';
  17. $response = $this->parse(['url' => $url]);
  18. $body = $response->getContent();
  19. $this->assertEquals(200, $response->getStatusCode());
  20. $data = json_decode($body);
  21. $this->assertEquals('feed', $data->data->type);
  22. }
  23. public function testListOfHEntrysWithHCard() {
  24. $url = 'http://feed.example.com/list-of-hentrys-with-h-card';
  25. $response = $this->parse(['url' => $url]);
  26. $body = $response->getContent();
  27. $this->assertEquals(200, $response->getStatusCode());
  28. $data = json_decode($body);
  29. $this->assertEquals('feed', $data->data->type);
  30. }
  31. public function testShortListOfHEntrysWithHCard() {
  32. $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card';
  33. $response = $this->parse(['url' => $url]);
  34. $body = $response->getContent();
  35. $this->assertEquals(200, $response->getStatusCode());
  36. $data = json_decode($body);
  37. $this->assertEquals('feed', $data->data->type);
  38. }
  39. public function testTopLevelHFeed() {
  40. $url = 'http://feed.example.com/top-level-h-feed';
  41. $response = $this->parse(['url' => $url]);
  42. $body = $response->getContent();
  43. $this->assertEquals(200, $response->getStatusCode());
  44. $data = json_decode($body);
  45. $this->assertEquals('feed', $data->data->type);
  46. }
  47. public function testHCardWithChildHEntrys() {
  48. $url = 'http://feed.example.com/h-card-with-child-h-entrys';
  49. $response = $this->parse(['url' => $url]);
  50. $body = $response->getContent();
  51. $this->assertEquals(200, $response->getStatusCode());
  52. $data = json_decode($body);
  53. $this->assertEquals('card', $data->data->type);
  54. }
  55. public function testHCardWithChildHFeed() {
  56. $url = 'http://feed.example.com/h-card-with-child-h-feed';
  57. $response = $this->parse(['url' => $url]);
  58. $body = $response->getContent();
  59. $this->assertEquals(200, $response->getStatusCode());
  60. $data = json_decode($body);
  61. $this->assertEquals('card', $data->data->type);
  62. }
  63. }