Skip to content

Commit 113b0a4

Browse files
committed
Update tests demonstrating #184 already fixed
1 parent 7daaefd commit 113b0a4

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,5 +1005,65 @@ 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+
$input = '<div class="vevent">
1014+
<a class="summary url" href="http://indiewebcamp.com/2012">
1015+
IndieWebCamp 2012
1016+
</a>
1017+
from <time class="dtstart">2012-06-30</time>
1018+
to <time class="dtend">2012-07-01</time> at
1019+
<span class="location vcard">
1020+
<a class="fn org url" href="http://geoloqi.com/">Geoloqi</a>,
1021+
<span class="adr">
1022+
<span class="street-address">920 SW 3rd Ave. Suite 400</span>,
1023+
<span class="locality">Portland</span>,
1024+
<abbr class="region" title="Oregon">OR</abbr>
1025+
</span>
1026+
</span>
1027+
</div>';
1028+
$parser = new Parser($input, 'https://example.com');
1029+
$output = $parser->parse();
1030+
1031+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1032+
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
1033+
$this->assertEquals('h-card', $output['items'][0]['properties']['location'][0]['type'][0]);
1034+
}
1035+
1036+
/**
1037+
* @see https://github.com/microformats/php-mf2/issues/184
1038+
*/
1039+
public function testVeventLocationAdrProperty() {
1040+
$input = '<div class="vevent">
1041+
<span class="summary">CPJ Online Press Freedom Summit</span>
1042+
(<time class="dtstart" datetime="2012-10-10">10 Nov 2012</time>) in
1043+
<span class="location adr"><span class="street-address">665 3rd St.</span><span class="locality">San Francisco</span>, <span class="region">CA</span> </span>.
1044+
</div>';
1045+
$parser = new Parser($input, 'https://example.com');
1046+
$output = $parser->parse();
1047+
1048+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1049+
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
1050+
$this->assertEquals('h-adr', $output['items'][0]['properties']['location'][0]['type'][0]);
1051+
}
1052+
1053+
/**
1054+
* @see https://github.com/microformats/php-mf2/issues/184
1055+
*/
1056+
public function testVeventLocationProperty() {
1057+
$input = '<div class="vevent">
1058+
<span class="summary">CPJ Online Press Freedom Summit</span>
1059+
(<time class="dtstart" datetime="2012-10-10">10 Nov 2012</time>) in
1060+
<span class="location">San Francisco</span>.
1061+
</div>';
1062+
$parser = new Parser($input, 'https://example.com');
1063+
$output = $parser->parse();
1064+
1065+
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
1066+
$this->assertEquals('San Francisco', $output['items'][0]['properties']['location'][0]);
1067+
}
10081068
}
10091069

0 commit comments

Comments
 (0)