createStub(ResponseInterface::class); $response->method('getHeaders') ->willReturn([ "link" => ["; rel=webmention"], ]); $response->method('getInfo') ->willReturn('https://webmention.rocks/test/1'); $this->assertSame("https://webmention.rocks/test/1/webmention", EndpointParser::parse($response)); } public function testParsesRelativeEndpointWithQuotedRelInResponseHeader() { $response = $this->createStub(ResponseInterface::class); $response->method('getHeaders') ->willReturn([ "link" => ['; rel="webmention"'], ]); $response->method('getInfo') ->willReturn('https://webmention.rocks/test/5'); $this->assertSame("https://webmention.rocks/test/5/webmention", EndpointParser::parse($response)); } public function testParsesAbsoluteEndpointFromHeader() { $response = $this->createStub(ResponseInterface::class); $response->method('getHeaders') ->willReturn([ "link" => ['; 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 = <<

Some content

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)); } public function testSkipsParsingEndpointWithNoHref() { $content = <<

Some content

The real webmention 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 = <<

Some content

The real webmention 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)); } }