More work on parsing endpoints in the body

This commit is contained in:
Lewis Dale committed 2023-03-08 16:07:43 +00:00
1 parent 4eba80387d
commit e5f7595321
2 files changed
+41

No files matched your search

+35
View File
@@ -35,4 +35,39 @@ class EndpointParserTest extends TestCase {
$this->assertSame("https://webmention.rocks/test/5/webmention", EndpointParser::parse($response));
}
public function testParsesAbsoluteEndpointFromHeader() {
$response = $this->createStub(ResponseInterface::class);
$response->method('getHeaders')
->willReturn([
"link" => ['<https://webmention.rocks/test/2/webmention>; rel="webmention"'],
]);
$response->method('getInfo')
->willReturn('https://webmention.rocks/test/2');
$this->assertSame("https://webmention.rocks/test/2/webmention", EndpointParser::parse($response));
}
public function testParsesRelativeEndpointFromLink() {
$content = <<<XML
<html>
<head>
<link rel="webmention" href="/test/4/webmention" />
</head>
<body>
<h1>Some content</h1>
</html>
XML;
$response = $this->createStub(ResponseInterface::class);
$response->method('getHeaders')->willReturn([]);
$response->method('getContent')->willReturn($content);
$response->method('getInfo')
->willReturn('https://webmention.rocks/test/4');
$this->assertSame("https://webmention.rocks/test/4/webmention", EndpointParser::parse($response));
}
}