Skip to content

Commit cf30431

Browse files
authored
Merge pull request #241 from gRegorLove/issue184
vevent location backcompat
2 parents 7daaefd + 8f07793 commit cf30431

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Mf2/Parser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,7 @@ public function backcompat(DOMElement $el, $context = '', $isParentMf2 = false)
16581658
if ( !$this->hasRootMf2($tempEl) ) {
16591659
$this->addMfClasses($tempEl, 'p-location h-card');
16601660
$this->backcompat($tempEl, 'vcard');
1661+
$this->addUpgraded($tempEl, array('location', 'vcard'));
16611662
}
16621663
}
16631664
}

tests/Mf2/ClassicMicroformatsTest.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,5 +1005,71 @@ public function testVcardGeoNoImpliedName() {
10051005

10061006
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']['geo'][0]['properties']);
10071007
}
1008+
1009+
/**
1010+
* @see https://github.com/microformats/php-mf2/issues/184
1011+
*/
1012+
public function testVeventLocationVcardProperty() {
1013+
// Note: The venue for IWC 2012 no longer exists so we switched
1014+
// this to Powell's since it's a long-term Portland institution
1015+
$input = '<div class="vevent">
1016+
<a class="summary url" href="https://indieweb.org/2012">
1017+
IndieWebCamp 2012
1018+
</a>
1019+
from <time class="dtstart">2012-06-30</time>
1020+
to <time class="dtend">2012-07-01</time> at
1021+
<span class="location vcard">
1022+
<a class="fn org url" href="https://www.powells.com/">Powell’s</a>,
1023+
<span class="adr">
1024+
<span class="street-address">1005 W Burnside St.</span>,
1025+
<span class="locality">Portland</span>,
1026+
<abbr class="region" title="Oregon">OR</abbr>
1027+
</span>
1028+
</span>
1029+
</div>';
1030+
$parser = new Parser($input, 'https://example.com');
1031+
$output = $parser->parse();
1032+
1033+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1034+
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
1035+
$this->assertEquals('h-card', $output['items'][0]['properties']['location'][0]['type'][0]);
1036+
}
1037+
1038+
/**
1039+
* @see https://github.com/microformats/php-mf2/issues/184
1040+
*/
1041+
public function testVeventLocationAdrProperty() {
1042+
// date fix, see: https://cpj.org/2012/10/cpj-impact-43/
1043+
// "second annual Online Press Freedom Summit in San Francisco on October 10"
1044+
$input = '<div class="vevent">
1045+
<span class="summary">CPJ Online Press Freedom Summit</span>
1046+
(<time class="dtstart" datetime="2012-10-10">10 Oct 2012</time>) in
1047+
<span class="location adr"><span class="street-address">665 3rd St.</span><span class="locality">San Francisco</span>, <span class="region">CA</span> </span>.
1048+
</div>';
1049+
$parser = new Parser($input, 'https://example.com');
1050+
$output = $parser->parse();
1051+
1052+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1053+
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
1054+
$this->assertEquals('h-adr', $output['items'][0]['properties']['location'][0]['type'][0]);
1055+
}
1056+
1057+
/**
1058+
* @see https://github.com/microformats/php-mf2/issues/184
1059+
*/
1060+
public function testVeventLocationProperty() {
1061+
// date fix, see: https://cpj.org/2012/10/cpj-impact-43/
1062+
// "second annual Online Press Freedom Summit in San Francisco on October 10"
1063+
$input = '<div class="vevent">
1064+
<span class="summary">CPJ Online Press Freedom Summit</span>
1065+
(<time class="dtstart" datetime="2012-10-10">10 Oct 2012</time>) in
1066+
<span class="location">San Francisco</span>.
1067+
</div>';
1068+
$parser = new Parser($input, 'https://example.com');
1069+
$output = $parser->parse();
1070+
1071+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1072+
$this->assertEquals('San Francisco', $output['items'][0]['properties']['location'][0]);
1073+
}
10081074
}
10091075

0 commit comments

Comments
 (0)