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.

37 lines
1.4 KiB

  1. <?php
  2. class LibraryTest extends PHPUnit_Framework_TestCase {
  3. public function testInputIsParsedMf2Array() {
  4. $html = '<div class="h-entry"><p class="p-content p-name">Hello World</p><img src="/photo.jpg"></p></div>';
  5. $mf2 = Mf2\parse($html, 'http://example.com/entry');
  6. $xray = new p3k\XRay();
  7. $data = $xray->process('http://example.com/entry', $mf2);
  8. $this->assertEquals('Hello World', $data['data']['content']['text']);
  9. $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]);
  10. }
  11. public function testInputIsParsedMf2JSON() {
  12. $html = '<div class="h-entry"><p class="p-content p-name">Hello World</p><img src="/photo.jpg"></p></div>';
  13. $mf2 = Mf2\parse($html, 'http://example.com/entry');
  14. $xray = new p3k\XRay();
  15. $data = $xray->process('http://example.com/entry', json_encode($mf2));
  16. $this->assertEquals('Hello World', $data['data']['content']['text']);
  17. $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]);
  18. }
  19. public function testInputIsParsedMf2HCard() {
  20. $url = 'https://waterpigs.co.uk/';
  21. $html = '<a class="h-card" href="https://waterpigs.co.uk/">Barnaby Walters</a>';
  22. $mf2 = Mf2\parse($html, $url);
  23. $xray = new p3k\XRay();
  24. $data = $xray->process($url, $mf2);
  25. $this->assertEquals('card', $data['data']['type']);
  26. $this->assertEquals('Barnaby Walters', $data['data']['name']);
  27. }
  28. }