Skip to content

Commit c5f4e91

Browse files
committed
Add rel-tag tests
1 parent 40455f3 commit c5f4e91

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/Mf2/ClassicMicroformatsTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,5 +927,31 @@ public function testHReviewRelTag() {
927927
$this->assertContains('Garcon', $output['items'][0]['properties']['category']);
928928
$this->assertContains('Garçon', $output['items'][0]['properties']['category']);
929929
}
930+
931+
/**
932+
* Should return the last non-empty URL segment
933+
* @see https://github.com/indieweb/php-mf2/issues/157
934+
*/
935+
public function testRelTagTrailingSlash() {
936+
$input = '<div class="hentry">
937+
<a rel="tag" href="/tags/testing/">Testing</a>,
938+
<a rel="tag" href="/tags/microformats">Microformats</a>
939+
</div>
940+
941+
<div class="hreview">
942+
<a rel="tag" href="/tags/phpmf2/">php-mf2</a>,
943+
<a rel="tag" href="/tags/mf2py">mf2py</a>
944+
</div>
945+
';
946+
$parser = new Parser($input);
947+
$output = $parser->parse();
948+
949+
$this->assertArrayHasKey('category', $output['items'][0]['properties']);
950+
$this->assertContains('testing', $output['items'][0]['properties']['category']);
951+
$this->assertContains('microformats', $output['items'][0]['properties']['category']);
952+
$this->assertArrayHasKey('category', $output['items'][1]['properties']);
953+
$this->assertContains('phpmf2', $output['items'][1]['properties']['category']);
954+
$this->assertContains('mf2py', $output['items'][1]['properties']['category']);
955+
}
930956
}
931957

tests/Mf2/CombinedMicroformatsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,5 +397,25 @@ public function testNestedValueDTProperty() {
397397
$this->assertEquals('1997-12-12', $output['items'][0]['properties']['acme'][0]['value']);
398398
}
399399

400+
/**
401+
* rel=tag should not be upgraded within microformats2
402+
* @see https://github.com/indieweb/php-mf2/issues/157
403+
*/
404+
public function testMf2DoesNotParseRelTag() {
405+
$input = '<div class="h-entry">
406+
<a rel="tag" href="/tags/tests">Tests</a>
407+
</div>
408+
409+
<div class="h-review">
410+
<a rel="tag" href="/tags/reviews">Reviews</a>
411+
</div>
412+
';
413+
$parser = new Parser($input);
414+
$output = $parser->parse();
415+
416+
$this->assertArrayNotHasKey('category', $output['items'][0]['properties']);
417+
$this->assertArrayNotHasKey('category', $output['items'][1]['properties']);
418+
}
419+
400420
}
401421

0 commit comments

Comments
 (0)