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.

86 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\HTTP\Test(dirname(__FILE__).'/data/');
  9. $this->client->mc = null;
  10. }
  11. private function parse($params) {
  12. $request = new Request($params);
  13. $response = new Response();
  14. return $this->client->parse($request, $response);
  15. }
  16. public function testListOfHEntrys() {
  17. $url = 'http://feed.example.com/list-of-hentrys';
  18. $response = $this->parse(['url' => $url]);
  19. $body = $response->getContent();
  20. $this->assertEquals(200, $response->getStatusCode());
  21. $data = json_decode($body);
  22. $this->assertEquals('feed', $data->data->type);
  23. }
  24. public function testListOfHEntrysWithHCard() {
  25. $url = 'http://feed.example.com/list-of-hentrys-with-h-card';
  26. $response = $this->parse(['url' => $url]);
  27. $body = $response->getContent();
  28. $this->assertEquals(200, $response->getStatusCode());
  29. $data = json_decode($body);
  30. $this->assertEquals('feed', $data->data->type);
  31. }
  32. public function testShortListOfHEntrysWithHCard() {
  33. $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card';
  34. $response = $this->parse(['url' => $url]);
  35. $body = $response->getContent();
  36. $this->assertEquals(200, $response->getStatusCode());
  37. $data = json_decode($body);
  38. $this->assertEquals('entry', $data->data->type);
  39. }
  40. public function testTopLevelHFeed() {
  41. $url = 'http://feed.example.com/top-level-h-feed';
  42. $response = $this->parse(['url' => $url]);
  43. $body = $response->getContent();
  44. $this->assertEquals(200, $response->getStatusCode());
  45. $data = json_decode($body);
  46. $this->assertEquals('feed', $data->data->type);
  47. }
  48. public function testHCardWithChildHEntrys() {
  49. $url = 'http://feed.example.com/h-card-with-child-h-entrys';
  50. $response = $this->parse(['url' => $url]);
  51. $body = $response->getContent();
  52. $this->assertEquals(200, $response->getStatusCode());
  53. $data = json_decode($body);
  54. $this->assertEquals('card', $data->data->type);
  55. }
  56. public function testHCardWithChildHFeed() {
  57. $url = 'http://feed.example.com/h-card-with-child-h-feed';
  58. $response = $this->parse(['url' => $url]);
  59. $body = $response->getContent();
  60. $this->assertEquals(200, $response->getStatusCode());
  61. $data = json_decode($body);
  62. $this->assertEquals('card', $data->data->type);
  63. }
  64. }