Finish implementing endpoint discovery for Webmentions
This commit is contained in:
1 parent
e5f7595321
commit
b63ada6dea
5 files changed
+312
-20
No files matched your search
@@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
use Lewisdale\Webmentions\EndpointParser;
|
||||
|
||||
|
||||
class EndpointParserTest extends TestCase {
|
||||
public function testParsesRelativeEndpointFromResponseHeaders() {
|
||||
$response = $this->createStub(ResponseInterface::class);
|
||||
@@ -68,6 +67,49 @@ class EndpointParserTest extends TestCase {
|
||||
->willReturn('https://webmention.rocks/test/4');
|
||||
|
||||
$this->assertSame("https://webmention.rocks/test/4/webmention", EndpointParser::parse($response));
|
||||
}
|
||||
|
||||
public function testSkipsParsingEndpointWithNoHref() {
|
||||
$content = <<<XML
|
||||
<html>
|
||||
<head>
|
||||
<link rel="webmention" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Some content</h1>
|
||||
<a href="/test/6/webmention" rel="webmention">The real webmention</a>
|
||||
</body>
|
||||
</html>
|
||||
XML;
|
||||
|
||||
$response = $this->createStub(ResponseInterface::class);
|
||||
$response->method('getHeaders')->willReturn([]);
|
||||
$response->method('getContent')->willReturn($content);
|
||||
$response->method('getInfo')
|
||||
->willReturn('https://webmention.rocks/test/6');
|
||||
|
||||
$this->assertSame("https://webmention.rocks/test/6/webmention", EndpointParser::parse($response));
|
||||
}
|
||||
|
||||
public function testParseRelativeToPath() {
|
||||
$content = <<<XML
|
||||
<html>
|
||||
<head>
|
||||
<link rel="webmention" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Some content</h1>
|
||||
<a href="153/webmention" rel="webmention">The real webmention</a>
|
||||
</body>
|
||||
</html>
|
||||
XML;
|
||||
|
||||
$response = $this->createStub(ResponseInterface::class);
|
||||
$response->method('getHeaders')->willReturn([]);
|
||||
$response->method('getContent')->willReturn($content);
|
||||
$response->method('getInfo')
|
||||
->willReturn('https://webmention.rocks/test/153');
|
||||
|
||||
$this->assertSame("https://webmention.rocks/test/153/webmention", EndpointParser::parse($response));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user