From 112b75b623e2200e6e57c96b09b1e068307d94bc Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sat, 14 Jul 2018 09:27:22 -0700 Subject: [PATCH] parse quotation-of from HTML as well closes #73 --- lib/XRay/Formats/Mf2.php | 2 +- tests/ParseTest.php | 16 +++++++ tests/data/source.example.com/quotation-of | 55 ++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/data/source.example.com/quotation-of diff --git a/lib/XRay/Formats/Mf2.php b/lib/XRay/Formats/Mf2.php index 8463be8..a5941ed 100644 --- a/lib/XRay/Formats/Mf2.php +++ b/lib/XRay/Formats/Mf2.php @@ -431,7 +431,7 @@ class Mf2 extends Format { // These properties are always returned as arrays and always URLs // If the value is an h-* object with a URL, the URL is used and a "ref" is added as well - self::collectArrayURLValues(['photo','video','audio','syndication','in-reply-to','like-of','repost-of','bookmark-of'], $item, $data, $refs, $http); + self::collectArrayURLValues(['photo','video','audio','syndication','in-reply-to','like-of','repost-of','bookmark-of','quotation-of'], $item, $data, $refs, $http); self::determineNameAndContent($item, $data); diff --git a/tests/ParseTest.php b/tests/ParseTest.php index f083817..c924730 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -779,6 +779,22 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals(1, count($data['data']['like-of'])); } + public function testQuotationOf() { + $url = 'http://source.example.com/quotation-of'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('I’m so making this into a t-shirt', $data['data']['content']['text']); + $this->assertEquals('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['quotation-of'][0]); + $this->assertArrayHasKey('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['refs']); + $q = $data['data']['refs']['https://twitter.com/gitlost/status/1015005409726357504']; + $this->assertEquals("Still can't git fer shit", $q['content']['text']); + $this->assertEquals('2018-07-05T22:52:02+00:00', $q['published']); + } + public function testHTML5Markup() { $url = 'http://source.example.com/html5-tags'; $response = $this->parse(['url' => $url]); diff --git a/tests/data/source.example.com/quotation-of b/tests/data/source.example.com/quotation-of new file mode 100644 index 0000000..71ce93f --- /dev/null +++ b/tests/data/source.example.com/quotation-of @@ -0,0 +1,55 @@ +HTTP/1.1 200 OK +Server: Apache +Date: Wed, 09 Dec 2015 03:29:14 GMT +Content-Type: text/html; charset=utf-8 +Connection: keep-alive + +
+ tag:twitter.com:1015014506651668480 + + + + + + + Michael Bishop + miklb + + + + https://twitter.com/miklb/status/1015014506651668480 +
+ + I’m so making this into a t-shirt +
+ + + + + +