Skip to content

Commit 40455f3

Browse files
committed
Add failing test and fix for #157 (hreview)
1 parent 38b2f2b commit 40455f3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Mf2/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,8 @@ public function backcompat(DOMElement $el, $context = '', $isParentMf2 = false)
15761576
}
15771577
}
15781578
}
1579+
1580+
$this->upgradeRelTagToCategory($el);
15791581
break;
15801582

15811583
case 'vevent':
@@ -1996,6 +1998,9 @@ public function query($expression, $context = null) {
19961998
'description' => array(
19971999
'replace' => 'e-content'
19982000
),
2001+
'category' => array(
2002+
'replace' => 'p-category'
2003+
),
19992004
),
20002005
'hproduct' => array(
20012006
'fn' => array(

tests/Mf2/ClassicMicroformatsTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,5 +888,44 @@ public function testHEntryRelTag() {
888888
$this->assertContains('wordpress', $output['items'][0]['properties']['category']);
889889
}
890890

891+
/**
892+
* @see https://github.com/indieweb/php-mf2/issues/157
893+
* @see source: http://jg.typepad.com/ciel/2006/02/daniel_bouluds_.html
894+
*/
895+
public function testHReviewRelTag() {
896+
$input = '<div class="hreview">
897+
<span class="version" style="display:none">0.2</span>
898+
<h2 class="summary">
899+
Divine Brunch!
900+
</h2>
901+
<abbr class="dtreviewed" title="20060219T1919-0800">
902+
Feb 19, 2006
903+
</abbr>
904+
by <span class="reviewer fn"><a href="http://jg.typepad.com/ciel">Joan Gelfand</a></span>
905+
<span class="type" style="display:none">business</span>
906+
<div class="item vcard">
907+
<a href="http://www.garconsf.com" class="url fn">
908+
Garçon
909+
</a>
910+
<div class="adr">
911+
<div class="street-address">1101 Valencia Street</div>
912+
<span class="locality">San Francisco</span>,
913+
<span class="region">CA</span>
914+
</div>
915+
</div>
916+
<blockquote class="description"><p>
917+
<abbr class="rating" title="3">★★★ </abbr>
918+
Best Benedicts!
919+
Two perfectly poached eggs and a thin slice of tasty, French ham rest on a circle of warm brioche. Drizzled on top is a light, slightly tangy sauce. Seamless! The sophisticated room and great wine list added to the whole experience - Super!</p></blockquote>
920+
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/Garcon" rel="tag">Garcon</a>, <a href="http://www.technorati.com/tag/Garçon" rel="tag">Garçon</a></p>
921+
</div>';
922+
$parser = new Parser($input);
923+
$output = $parser->parse();
924+
925+
$this->assertArrayHasKey('category', $output['items'][0]['properties']);
926+
$this->assertCount(2, $output['items'][0]['properties']['category']);
927+
$this->assertContains('Garcon', $output['items'][0]['properties']['category']);
928+
$this->assertContains('Garçon', $output['items'][0]['properties']['category']);
929+
}
891930
}
892931

0 commit comments

Comments
 (0)