Commit 70cc3c19 authored by Aaron Parecki's avatar Aaron Parecki

add tests to ensure rel values are returned in document order

parent c8ddd266
......@@ -41,6 +41,51 @@ class RelTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('http://example.com/webmention', $output['rels']['webmention'][0]);
}
public function testRelValueOrder() {
$input = '<map><area rel="webmention" href="http://example.com/area"/></map>
<a rel="webmention" href="http://example.com/a">webmention me</a>
<link rel="webmention" href="http://example.com/link">';
$parser = new Parser($input);
$output = $parser->parse();
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('http://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('http://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('http://example.com/link', $output['rels']['webmention'][2]);
}
public function testRelValueOrder2() {
$input = '<map><area rel="webmention" href="http://example.com/area"/></map>
<link rel="webmention" href="http://example.com/link">
<a rel="webmention" href="http://example.com/a">webmention me</a>';
$parser = new Parser($input);
$output = $parser->parse();
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('http://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('http://example.com/link', $output['rels']['webmention'][1]);
$this->assertEquals('http://example.com/a', $output['rels']['webmention'][2]);
}
public function testRelValueOrder3() {
$input = '<html>
<head>
<link rel="webmention" href="http://example.com/link">
</head>
<body>
<a rel="webmention" href="http://example.com/a">webmention me</a>
<map><area rel="webmention" href="http://example.com/area"/></map>
</body>
</html>';
$parser = new Parser($input);
$output = $parser->parse();
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('http://example.com/link', $output['rels']['webmention'][0]);
$this->assertEquals('http://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('http://example.com/area', $output['rels']['webmention'][2]);
}
public function testRelValueOnBTag() {
$input = '<b rel="webmention" href="http://example.com/webmention">this makes no sense</b>';
$parser = new Parser($input);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment